{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Symbolic computation\n",
    "====================\n",
    "\n",
    "SymPy\n",
    "-----\n",
    "\n",
    "In this section, we introduce some basic functionality of the SymPy (SYMbolic Python) library. In contrast to numerical computation (involving numbers), in symbolic calculation we are processing and transforming generic variables.\n",
    "\n",
    "The SymPy home page is <http://sympy.org/>, and provides the full (and up-to-date) documentation for this library.\n",
    "\n",
    "Symbolic calculation is very slow compared to floating point operation (see for example [symbolic calculation for decimals](13-numeric-computation.ipynb#Symbolic-calculation)), and thus generally not for direct simulation. However, it is a powerful tool to support the preparation of code and symbolic work. Occasionally, we use symbolic operations in simulations to work out the most efficient numerical code, before that is executed.\n",
    "\n",
    "### Output\n",
    "\n",
    "Before we start using sympy, we'll call `init_printing`. This tells sympy to display expressions in a nicer format."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import sympy\n",
    "sympy.init_printing()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Symbols\n",
    "\n",
    "Before we can carry out any symbolic operations, we need to create symbolic variables using SymPy’s `Symbol` function:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "sympy.core.symbol.Symbol"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sympy import Symbol\n",
    "x = Symbol('x')\n",
    "type(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAABy6+R8AAAABHNCSVQICAgIfAhkiAAAAMBJREFU\nKJHF0bFLwkEYxvFPNZVLIE4ShRDo4KKTv9ZAml0cHIOWtmZpcom2wNndqT+gQXARx7ag0am/oCUd\n7hech0K69Cx333vveY/nXvbQQcJN9LDEBW5xh1OU8YjP2HCJl6jRCB/IcIUfPKSvDlGIeIxZvj/D\nM4qp6TzhBQbbcm1STch1vYvpHt84ic4q6aVjPKGe8yvmUf1QyLymjvA7XVTxjmlU76P1C0f5+oWS\nMI+GMKsMN2jjDZO/Jft3rQCgLBpNY0ETtAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$x$$"
      ],
      "text/plain": [
       "x"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y = Symbol('y')\n",
    "2 * x - x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEwAAAAWCAYAAABqgnq6AAAABHNCSVQICAgIfAhkiAAAAqBJREFU\nWIXt2F2oTWkYwPGfk+8zSpKvc8GcKMIFIiE3yDTlQrlQ5Eq5kgYXSiFCIS4oSVjyfeNOEzdmzCQ1\nNflKUWiUmnymJB8NLp61WZa9z1nn7H3swf7Xaq/3eZ/1vs9+3vd51vMuGlTFFJzGr7iGA2ipq0Xt\n0xdXa6hXmIk4h/5p+wdcwAOMqOVEOXpU8exk/IV3NdLrEGcwMiebkE5yspYT5div47t4jLA3wSWV\nHVFUr1M8xz0Mysmf4lEtJ8qRqG4HJ4o5oqhemzRl7u9iMJpzOq/Qp9qJvhW6Z+6noh/+zciGCSf+\nlntuEhaLFRuBpVgm8l8L1uN2VxjcRbRiJX7EMRzP9K0SOXBhkYG24D9My8hGYTe6pe0Et1Kd6Xib\nTlKURP1Dci96YoXP36RXcKrUaFKZVizHVlzMyH/BmszkzSLPXRQ5cGdq3NfCDPyB1/hJLH6J/hiH\n39sbpJd4q+ws0zc8176PzQUMO4zLZa4nuFGhb1KBcRPV7bAh4v+2iGian+mblz4ztr3Bj2BjASPG\npAPOLqBbiUT9Q5KInGfCeSW24aGP6adsSG4Q23JdRrakwiSzxFbOhmxrG0b9n5mL86IqKDFTFO8f\nHJ132OJUtiknn5H+9hFeH5+254gk+SIz3uoqDa8Xw3Ez024Wp59P8le2rJiJXTiLozmdkod/Fg75\nG2/EbnqW0V0rwvlL0jv97evjwnVG7x8MyLS3iWNbxYT/WDim3FXacQNxENvTq1kk832i1JjThsGV\nSHQ8hw0SC3s9Y+NDEVKLOqEHo/En9mCHeHM+0XYlURcSXXu47wxNooA/VG9DyjFRdV8sasEJnxas\n8/FSFOkNyvBIpBTiOHhHhaNQt3LC75AF4uNpE4YK512qq0UNGjQownuvxJ720vwq9wAAAABJRU5E\nrkJggg==\n",
      "text/latex": [
       "$$2 x + 11 y$$"
      ],
      "text/plain": [
       "2⋅x + 11⋅y"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x + y + x + 10*y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADgAAAATCAYAAADF7c7rAAAABHNCSVQICAgIfAhkiAAAAgNJREFU\nWIXt18+LTmEUB/APxq8ZxiTZTIMwMQk1b35kpbDgb7CYomRBKTYsrCSKsiGxeCUrO5rtlNRQEmGl\nLPyIsFA0aoixOPeaZ3TvTO+883ql+dbtdM95nvt8v+eeezqX/xwzmk1gHLTiPjaUxNfgNF5iBEtw\nDO//CjvMrmPvJjwQxIuwCG+wN/EdxzPMqePcmnAFnTXu6UE/quLtlQk8hQ9oSXyL8R0Hazxz0qhi\nRZ37ywQ+x+0C/1MMpI6ZdRBoFhaiG68KYm9RSR0tfyyoiLoeEdnfjwPoEOV2Ei+mlG7tWJ7ZzwWx\nIbRjLoYZK7AbfTgsBFbFd9Anuu1dPMK5KadcG9oz+60gNpTZDlk3TQUeEW02r/s2fMIgunBeiG42\nfmS26PvMO/es3JEKPGM0A7DNqKDXOFpy4DVsLPAvw2bFmd6HhyXPmwgfx4m1ZfbLRA/pERnaOUkS\nNK6LtuEnLhTEBkTV/UZZF90hMj+Y+FbWTLExGBK9oKsgthqPU0cucD7OYn12vwtP8DVZV1aizUA/\nthg7aq4Som+mC3OBe4SAdVgr3tZwsu4ErjeIbBnmZba1IHZJlGo6qh0So9rVdGHeZO6Imq9k11Zc\nxGVRqrdwb2p4j4ulIpGdItnEMJ0Tv5H53mG7GNl6sUCMarsVN7WGoKq+JvPPo1d9fxTTmAZ+AdGc\nXTtwhggcAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$x + 10$$"
      ],
      "text/plain": [
       "x + 10"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y + x - y + 10"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can abbreviate the creation of multiple symbolic variables using the `symbols` function. For example, to create the symbolic variables `x`, `y` and `z`, we can use"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEAAAAAWCAYAAABwvpo0AAAABHNCSVQICAgIfAhkiAAAAvBJREFU\nWIXt2F2IVVUUB/Cf4zeTZglpmRSmNhKFjhARfvQQ9VKgkCEiIShYvYgEYQUqlhkWBSkp+NCtLI16\nUkJMUFKjQSRLIagHxSAINU0lTcH0YZ1Le87c7+No0PzhcO7+r/2x9tpr7bXO5X+Ofrn2w1iGobgb\nB7Acv91gverhESzGRaHrUKzGkSKTduJrjMjat2AvTuDeIhPXwMAWxkzBNgxJuA9wDpOLKPMVxldY\n7Cq2Fpm4BjZhTJNj3hM6zUm4pzLu/WYVaEt+z8Ru3JFwh/AnHm924gYxUPNecEic9tmEG5a9LzSr\nQGqAYxiF9lyfSyLG/iv4GLeKcC2jE1ewpcjE7Rid4+4SrrUn4cZhvQiZebn+L2kuXEqK3y/34SRe\nqCJflMmP4MGMW4MHGpn8TWHZRxNuAwZhCQ7n+v+IzxuZOENJ6waYhXX4Ba/omdFgurjIV+AtfIb9\neLWRBcbhPN5IuGn+PfUd+DKRjRDGerHRHbg+HjBIeOi3GJmTTcSApP2sMEKbOhiMLryb40dnsjFi\ns7MT2dMiXCq51kf4ocJzGj9VkU2tp2SCx7K1v6jRZyE+1d0gVfEJVtWQLxW38OCEWytirZIrVkNJ\n8x7QgYdy3HBhgH9E/ZLHy9iowslXcoWVIq6WJ9xzuT5PCre7lHAzRLxdrap6cQwXafB7cfmVcSV7\n90P/3JhVIms8LwwEt5WFeQPMz7jXc/y0XPse/Jy020Uq+qbeDgrisnDhYziT8JOy90Hd64OVwiiv\nJVxH2k7jYYaosnZic8IP0PNUj+P2pL1WFDS9bYC/8bYoz1MDLMFfuqfCWeKbYbtw/18xFk+IO6MH\n/hAbrfTkPaJDpJP1eAf7xIVW93bNoaS1LLBA1BubsUuk3omJfJhIkeX7aJmoHr/D/S2sVxNt+B0f\ntjC2pPc+tHoNW3QvgGYL15zQwlydWvsivKk4JdyLKJWPYu7NU6cYmsnZZTwj/jhpw53CGF3XU6k+\n9KEPNwzXANPSlluBTFcEAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$2 y + 3 z$$"
      ],
      "text/plain": [
       "2⋅y + 3⋅z"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import sympy\n",
    "x, y, z = sympy.symbols('x,y,z')\n",
    "x + 2*y + 3*z - x"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Once we have completed our term manipulation, we sometimes like to insert numbers for variables. This can be done using the `subs` method."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADgAAAAWCAYAAACVIF9YAAAABHNCSVQICAgIfAhkiAAAAmBJREFU\nWIXt11uITlEUB/CfadA01MTkNmmYTJE8MLnE5AUp5WHKgzR5UsqLXN6EieFhEg+KB+STe+RBSXhw\nedB4kUspyrWUXBNpEONhny97TjN835lvRmr+deqstdde+7/O3mvtdRhAv2MWzuEi7uMQav4pox4w\nOMOcGbiMqkQehht4jQmloVU6HFD8l7+ASSnddHTiVClIlRI5xX/1z3iBUSn9B7zNQqIsy6Q+xFOM\nRmVK/xUVWRyWp+QGNAtHYgJWYbWQEzXYisdZFioQczAcryLdOCHoa5GuDusxEcdxIhrbgJlYnnZe\nj70YlMg5PMJczMPPZHKhyClNYdiJHwmPPPZjCNbiXsr+Lk5352ifrkfjDG4l7+OxCyOLIJbT+wDr\n8Amtka4RK5L3izgbjVUJH2NNd85qU/JL7CiAxBHc6eZ5jwc9jDUU4Hco2rE7pR+TjNUIwTRFY0uF\n9Jr6N+dTEsOFBRDpCTm928Gj2PaH8XX4KASbRxve+J1mPVbRBfiGm5GuLhPNbGgR8n9LpFuZslmM\nq0KFzWO+0Bh05hX5ACuE6Kcl8iIheb9Edht7z7sgNCfrbU/pG1NyLR5GcqXQCV2PjfLXxBIhgNv4\nLuzWx8huk3Bk+hrzsQeXcCzSl4t2JcFzjIjkNqE97BJg/qxWJwbvErlFqKodwlE9jytFks0lfp4V\nMeedrqRjtGJzJE/GQaFodWC2UFyqhSutz5HTfw1ymdAcHO6n9RDyIcsfRSE4qesF3yTsYn0frdfv\neCt0XYRW7oluWjOi++I/wzLhx7gMY4Vg2/8powEMIBt+AZzMc4HDNi6AAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$x + 2 y$$"
      ],
      "text/plain": [
       "x + 2⋅y"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sympy import symbols\n",
    "x, y = symbols('x,y')\n",
    "x + 2*y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADgAAAAWCAYAAACVIF9YAAAABHNCSVQICAgIfAhkiAAAAmBJREFU\nWIXt11uITlEUB/CfadA01MTkNmmYTJE8MLnE5AUp5WHKgzR5UsqLXN6EieFhEg+KB+STe+RBSXhw\nedB4kUspyrWUXBNpEONhny97TjN835lvRmr+deqstdde+7/O3mvtdRhAv2MWzuEi7uMQav4pox4w\nOMOcGbiMqkQehht4jQmloVU6HFD8l7+ASSnddHTiVClIlRI5xX/1z3iBUSn9B7zNQqIsy6Q+xFOM\nRmVK/xUVWRyWp+QGNAtHYgJWYbWQEzXYisdZFioQczAcryLdOCHoa5GuDusxEcdxIhrbgJlYnnZe\nj70YlMg5PMJczMPPZHKhyClNYdiJHwmPPPZjCNbiXsr+Lk5352ifrkfjDG4l7+OxCyOLIJbT+wDr\n8Amtka4RK5L3izgbjVUJH2NNd85qU/JL7CiAxBHc6eZ5jwc9jDUU4Hco2rE7pR+TjNUIwTRFY0uF\n9Jr6N+dTEsOFBRDpCTm928Gj2PaH8XX4KASbRxve+J1mPVbRBfiGm5GuLhPNbGgR8n9LpFuZslmM\nq0KFzWO+0Bh05hX5ACuE6Kcl8iIheb9Edht7z7sgNCfrbU/pG1NyLR5GcqXQCV2PjfLXxBIhgNv4\nLuzWx8huk3Bk+hrzsQeXcCzSl4t2JcFzjIjkNqE97BJg/qxWJwbvErlFqKodwlE9jytFks0lfp4V\nMeedrqRjtGJzJE/GQaFodWC2UFyqhSutz5HTfw1ymdAcHO6n9RDyIcsfRSE4qesF3yTsYn0frdfv\neCt0XYRW7oluWjOi++I/wzLhx7gMY4Vg2/8powEMIBt+AZzMc4HDNi6AAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$x + 2 y$$"
      ],
      "text/plain": [
       "x + 2⋅y"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x + 2*y.subs(x, 10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    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iPFdNTQdAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$2 y + 10$$"
      ],
      "text/plain": [
       "2⋅y + 10"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(x + 2*y).subs(x, 10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABYAAAASCAYAAABfJS4tAAAABHNCSVQICAgIfAhkiAAAAStJREFU\nOI3l000rxFEUx/HPaJDJQpOnHaXkoexsJNnwEpTsrLwAL2Ds5TXMCmWhZGNlh1jYKJspJbupoSwY\nD7H4XzWm/1z5l5Wzud3fOed7zz33XP7Ici30As4wFckdRQlPqIe1hMdWCdO4wEcEOoFbzIT9IG4C\nGOQbgsexiSreI9A89rGFk6C1oxv3kTxQjlS8ihf0xABtP52QYsuo4CEWlI85UyyHWZxjDouSFgxj\nA5c/AcrSW9Eb9GusNejzkmmYzAoeCPozupp8dzj82vy2x7WwViRz2wxeQGcW8KtkHGspvjo6UMwC\nJvmRfSl6Z4BXs4J3MOR7j3MYwwHeYsm7kkcqpPjacIr1Bm0pVDqcBuvHEa4C9CMEH2OlKbYomZw9\nbIdbjMQq/cf2CS+8PU4OkYAWAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$16$$"
      ],
      "text/plain": [
       "16"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(x + 2*y).subs(x, 10).subs(y, 3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABYAAAASCAYAAABfJS4tAAAABHNCSVQICAgIfAhkiAAAAStJREFU\nOI3l000rxFEUx/HPaJDJQpOnHaXkoexsJNnwEpTsrLwAL2Ds5TXMCmWhZGNlh1jYKJspJbupoSwY\nD7H4XzWm/1z5l5Wzud3fOed7zz33XP7Ici30As4wFckdRQlPqIe1hMdWCdO4wEcEOoFbzIT9IG4C\nGOQbgsexiSreI9A89rGFk6C1oxv3kTxQjlS8ihf0xABtP52QYsuo4CEWlI85UyyHWZxjDouSFgxj\nA5c/AcrSW9Eb9GusNejzkmmYzAoeCPozupp8dzj82vy2x7WwViRz2wxeQGcW8KtkHGspvjo6UMwC\nJvmRfSl6Z4BXs4J3MOR7j3MYwwHeYsm7kkcqpPjacIr1Bm0pVDqcBuvHEa4C9CMEH2OlKbYomZw9\nbIdbjMQq/cf2CS+8PU4OkYAWAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$16$$"
      ],
      "text/plain": [
       "16"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(x + 2*y).subs({x:10, y:3})"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can also substitute a symbolic variable for another one such as in this example where `y` is replaced with `x` before we substitute `x` with the number `2`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEAAAAAaCAYAAAAHfFpPAAAABHNCSVQICAgIfAhkiAAAAupJREFU\nWIXt2FGIlUUUB/Cfa7qKtYkFaiKGIriIUgpZGiJoGFKQoBE9SS+hLyKKEBEsRESrFVToQ0I3FVSU\nHgQV7CEKEgWxVAhSyHoIokxJUFfL1Yczl539uur9dr33Ju0fPubOOfOd+X9nZs45c/mfY1irCTQJ\n8zAfD2MB3sY3LWXURDyId7P+y7iCSa2h03zMRi+mpX4HbgpHeKAw+Gm8jqsYnZ53cLoZTBuE03gG\nP6X+5NSeLQ58EvsxKpNtwSU80UCCIxpouxZ24P1aig/F1liZyV5Iso8aSOhTzTuPr6FbFvzbMuV3\nYrX/ymQPpfZKA0mN0JxdsCy1G9GOx+nvgO0iTRzOZHNwA7saz6+hWIiJOIgJeD7174hp+AOra+jm\niiPzAb7AOLyB97BTX8StBxVpNUpgKj7BAbxa0K3H7sLYS+Io50/H7Yy/hI9xRnxUsVianvRVeSWN\nnS+KjN5Eol5UlHfAVozEWpwq6E5iT0l7NTESX+FbPJLJt2BM1t+LY+n3ZGwujL8bKso54Fl9q34I\n+zLdWHFk15Swd0csEttlbyabUhjzq6gV7obP8X2N5wJ+uI1ubg07E0QQmyQ+dnmmezHxnVkHn39h\nhqiaclSrpl5RUhbRmfRLBjJhQkX5IwDrRMZqz2TdIm7VfcepZoEOkQZP6B/AbqR2GIbXeH8xruNI\nJpta7+SDxFJxRK9lsoXiknOzXiNVB1wXZfE5XMz0nak9Lrw9Wnh5VpI/J4JQtU5ow4Z6Jx8kpuDH\nrD9GpO2vyxip3gV6sAm/6++AtbisLxUuEx94An+L1c4LpzdFqdkM/CLSbxXdoqAq5YDiWVklioR/\nMF4EqLdEmoNH00R/pn6XyAo9Yhftx5dlCIgY0IWfS743A9tEsOwRd/6ZiWNvSVstRcXAgmCONvyG\nzwZLphWYo/xdYJf+BdBysQum3ytS/3WcF9UoPCbu+q8MxND9+p/gCjwltv5E4YyjLWU0hCEM4b7E\nLY5LkjdEV6RQAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$3 x + y^{2}$$"
      ],
      "text/plain": [
       "       2\n",
       "3⋅x + y "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "myterm = 3*x + y**2\n",
    "myterm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEAAAAAaCAYAAAAHfFpPAAAABHNCSVQICAgIfAhkiAAAAodJREFU\nWIXt11uoTlsUB/Cfy3bJsQnllo5IiORSjlvyxOlEUUie5EUetJNSHpSS1JYUch4oHx6QFykevOgc\nHjwot1LI7U2IKNfcHubcNb/Fzlrr+z429r9WszHmGnP9x1hzjDkmvzm6lLT7C7PQD7OxFf/Xi1RH\nxx/YnsjL8QrDfwyd749J+IjRUW7GJyEQPx26l7C5jpm4G+URcbxdF0bfxgyswWv0js+2yOuH4Ah2\nlrBrKmEzBafQK9HtwwtMLrFezViNVuWK6X7F68YuId2WJbqFUbe7BAddyxhF/BPHjeiJkQXtmxTf\nBZeFv/080fWN46uCa6F8AOZiKM5gCP6OcqNxWDh6zya6qfiAo7UuPgp7cRorM3MbcCx574Ww7dKn\nueD3KorvmixG4zHWZvR5fanCv+iBFlzLzF3F8RrJZlFRPgCLsQe3sMmXNSi3L20pMAfn8U7YzrcS\ng/6YiP9Kkm0ETmKdwGs+LmBgnCvlyxChkA0X8mlJMrdI2OITSpI9hCtfeZ7iRjtz0wqsPy/yOxHl\nmnxZL1TYnomuVcizsveG9lBRPAXGCZ1oirZO9KPQprchly/ZTnABzuFtopsrXHQ+FSRbbzQLx2AT\nxuJO1H+IYxd0S97P5Uv2GPwTNxO5j3DMdIT8fyf8sHt4lujHx/GS6v4gly/ZHfAAAxK5VYh4RwjA\nG+zAI9UBaMFLXx6FuXzJ5vU4HBAK0Rvh3j8Bg4Qcqycq2IL7Be1WCdX9PQYLxXSz6mpPHXzpioc4\nWJBgXlTU3gjlRS5fjqpuGpYIkRvTIFJTlbsR5kEpX54I3RUME+77KxrB7jsgty9pDViK6cJ2GRoX\nuNg4jg3Fr+RLJzrRiQbiMyvtmtC3WGnAAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$y^{2} + 3 y$$"
      ],
      "text/plain": [
       " 2      \n",
       "y  + 3⋅y"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "myterm.subs(x, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABYAAAASCAYAAABfJS4tAAAABHNCSVQICAgIfAhkiAAAARNJREFU\nOI3l1E8rBWEUx/GP/3Xl+pOUIgskGynJi8EL8AJs7GXJ3sZSyUoWNmyVBcXKjqSuuxHdDelazHNr\n3J6ZyZSVU9Pp+f3mfM95ps7wR9GRoVdwiYUMfw47eEATo9hELa/ZMq5CQSwG8YS1lLaFO/TGCuZx\nioMwbRZ4Gy/oTmkj+MRG3sQCPAt8j5OIfovz1qGzqENbDGAWjxHvGUtlwVMhv0W8BqroKwOuhvyR\nAYahMuCvkGPfvyfkrjLgeo7XH/J7GXBNMu1wBvi1LLiBa0xGvBnctA6/BZMs0Yqfv4Pp0OyoqPhQ\ncuVKxBuXXHk9pe1JFiS60mM4k+x8Mzx1XGC17d3FMPku9nGMiaJp/2l8A5n7NHNNRyX7AAAAAElF\nTkSuQmCC\n",
      "text/latex": [
       "$$10$$"
      ],
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "myterm.subs(x, y).subs(y, 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "From this point onward, some of the code fragments and examples we present will assume that the required symbols have already been defined. If you try an example and SymPy gives a message like `NameError: name ’x’ is not defined` it is probably because you need to define the symbol using one of the methods above."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### isympy\n",
    "\n",
    "The `isympy` executable is a wrapper around ipython which creates the symbolic (real) variables `x`, `y` and `z`, the symbolic integer variables `k`, `m` and `n` and the symbolic function variables `f`, `g` and `h`, and imports all objects from the SymPy toplevel.\n",
    "\n",
    "This is convenient to figure out new features or experimenting interactively\n",
    "\n",
    "    $> isympy\n",
    "    Python 2.6.5 console for SymPy 0.6.7\n",
    "\n",
    "    These commands were executed:\n",
    "    >>> from __future__ import division\n",
    "    >>> from sympy import *\n",
    "    >>> x, y, z = symbols('xyz')\n",
    "    >>> k, m, n = symbols('kmn', integer=True)\n",
    "    >>> f, g, h = map(Function, 'fgh')\n",
    "\n",
    "    Documentation can be found at http://sympy.org/\n",
    "\n",
    "    In [1]: "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Numeric types\n",
    "\n",
    "SymPy has the numeric types `Rational` and `RealNumber`. The Rational class represents a rational number as a pair of two integers: the numerator and the denominator, so `Rational(1,2)` represents `1/2`, `Rational(5,2)` represents `5/2` and so on."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sympy import Rational"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAeCAYAAAAl+Z4RAAAABHNCSVQICAgIfAhkiAAAAN5JREFU\nOI3t1DFOAkEUxvEfSKiwMFpAQzChpMQDWFh7AAsaG6g4gmeg5QqcRBJDY2JrY6UxJsZQgcW4ATbs\nZsNiSIB/M5l5me+9vHnf8M+cYoT6Jpfv8YA5GnmqSBUo5lE+CgROUmJ36KGNGqp4zJtwHyn8rfOd\nVrFVkvzfxgAdDNFcdznJ/2W8CsMEVxinVREXuMHz0r6Ab1ySzQsNfMQSfKKVVeACP7GzqdCvTAJf\nFvMSUcF7VoEXwYkRJZwJjV1LvIklvFk87TWeouDyf5Dk/xkm6OIct+hbbexB8wuJJSM56b93mAAA\nAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$\\frac{1}{10}$$"
      ],
      "text/plain": [
       "1/10"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = Rational(1, 10)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAeCAYAAAAl+Z4RAAAABHNCSVQICAgIfAhkiAAAAZpJREFU\nOI3t1E+Iz0EYBvDPIqVdK63/NovlV+ziJktbapOklfMqtqS4OjkoVw726rC13BwdXRxccODgoLTr\nItFuSYlsIv0c3pl+07exHBXvaZ533veZed+Z9+HP7CC2ogubcOh3CTcwWuA7aOMHnmB33lhRSR7F\nJO4XvtfYnNYLZXCToBcH8LJCvFDxWdbAFzBdievGeUzgNoZqZOMYTuuHOFrsjYgGwjHM5sPzDbZg\nLV7UmPFUNBFeoYV9dHpwXDzPlYRb6brd+IAHWIevWJ1ivv/iMETXcwn9uFbsXcSjDJY3EvtxFWPY\niM94Jl7nlHji/aLZX5a6wb9k+XO0l4z6q62rgc9im5i8NbiJt+hpxN3FpSbZJK6n9XZ8Ex/rMgax\nI/lvoa+ZvBLvMVD4dgoRKYMncLhMzNM4IoZlAGcwhV2YF8NEaGILj5unZ+a2jg724GMqIdtMKqNq\nJxPBqsI3LyYPNuBNLTGX8DwRlNPZ1tGLE0UpVYJ3QsaOJLxeiMm9hIexWCMoVfmcEI692IPTiRg+\nYa5G8N/4CfBrQm4Nw8UdAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$\\frac{45}{67}$$"
      ],
      "text/plain": [
       "45\n",
       "──\n",
       "67"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b = Rational(45, 67)\n",
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABcAAAAeCAYAAADHJYVoAAAABHNCSVQICAgIfAhkiAAAAZxJREFU\nSInt1r9LV2EUBvBPKgZhiRD9xmrQLYII+0XwtcLBCEKQwgKXamisJUSwqCVob6jZ/8GlBJeooSUI\nGvJLgRE1GBJpaDa8R7zcbnqDazX4wOV9z7n3Oee87/tw3ssaorHkd4dwB3txGZ8wVUUBrRHsQNjb\n8BYNVQTvwyKaMr4POLEasUz2mRibM75NOFhF8Kd4ia6wjwWvtYrg8+iWKr2IWXxV0YHChsx8ayTY\ntRqp7Im/x/GYX8NDJSovq/MGSYJn0IIh/CjJXcdfxJLEFv9pFf8d8jrfjFE8w5eM/6TUBY/gBqZR\nz3HvYw7vihJdwW1p//fl3n3GYMz7pd7Skkv+EbUsKdujH8c4UpC4hsmM3WxZDFukpvY6TyrbW15F\ntaTL467lPn8Vj4pITUXO36ALPfiGB+E7hzFpr3/Bn9yDz3Evxgm0o01aVSHKBD8qHdb+sMelv4EL\n2I1b8XRiAGdXCpZXy2E8wcawe/EdHTleXU4tWZ1fwvUIthM7pC2YwgJOxSrO4yZeBG8PhnEa26WD\nfrNS9etYO/wEB65FwbaBib8AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$\\frac{9}{134}$$"
      ],
      "text/plain": [
       "9/134"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a * b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACcAAAAeCAYAAACv1gdQAAAABHNCSVQICAgIfAhkiAAAAjxJREFU\nWIXt111oz1Ecx/HXbM1Dk2Qe1rT9PSS0mgvPUVMeUivSPORp3HFFLimSFIZbuREXzJ2UK4krImMU\nJSmpeQp5aJ6XuTjn3377u9g/nRW1d/0753u+53P6ds75/s73zz9MSaJ1FmI8hqEBp3At+iagEd8x\nFpfQXoQuGW/RHPur8RkV0W7JzCvBuSJ1yhIF14CnGbtcz6mswBk8QHcMoBhdv9CKvRl7B37gCHaj\nvkhdsp2D2ViKrziaGT+POWjCUNwsUtcvbMMd4e4MxwXhwg/BfnxArg9dMubitZCVMFW4W01YhZ0F\n8w9iTR86MChBcF14iBfRnoifuI8nmFEwvxS3+tAhXWZsFL5hv7AAJ3E5+tYK96oDg9GGK0XoBvhr\nssdaj9OKP+p2bE0d0H9DioToTrDGAElJWQFsRg1eYQSOxfEOfz5JrdiOmVF3R/jOHRY+3EnZgkOx\nnxOqkEqMwy5MEp6pHE5glFAePUNV1M3C7dSBleMNajNjE2NbFQPJsx7zY3+J8HzlKUGnnrc2yds6\nT9ilWmzAcUyOvpd4F/vVmIIb0c5lfISsf4+6/ECKeq46s/hZXBTuWV1s8xyIvzyV+FKw1jehzEKa\nnfsY27bYdgqFY2Nmzhgs1rsk/+jPhKwQ/lckC+6esGulmbFuvU9lud5HCI+EhMlThpFCkiTlKpbF\n/mhhV6oz/hZcL9CUCbVcTbQX4W7hhBQ0Yx+mYxpW4nnG/wmPCzRd2IQ9QpI0YF2ieAYY4K/4DZsy\ne1S17qVvAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$- \\frac{383}{670}$$"
      ],
      "text/plain": [
       "-383 \n",
       "─────\n",
       " 670 "
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a - b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABcAAAAeCAYAAADHJYVoAAAABHNCSVQICAgIfAhkiAAAAftJREFU\nSInt1rtrVEEUBvBfzBIEE0SMIRLR+AQ1YKOSqIWCQQQL7cTgA7SxFbsUCjZK0EpIpzZiY+M/YOWj\n8IGNoiKIEh+gopGgwQdrMXPdyexN3MJXkQ8uM+ex35w95863Sw3r0YUmdKLXb8QFVPEdN7E8i7fh\nMhZm/hF8yJ7hnPy4UHFnycGHYryK7sTfiSNYisUxNoy5ZeS/Qk4+PyPagw2FMSMJzMLBmHAeqxs4\n7BXexX0XVuBGWWKfMEzox6Ps8LLKU5wTWlOKSrLvjkRrGiTvwPPcWVTWK0x5ZrTb4vp1skoybFdr\nTx35CIYwHu2NQu8eNEjeg0+5s2jFCO7iKJqFwexK8gawKe5P4hrOJvGPeNxgIdP4gyguTfWfVvHf\noSmz9wl6/RqzcVq4A61Z3iUcxtr4mTvCPTiFJ2UHHRAuCEE/vmCByfW6Bc8E2YV1uFVG3II3WJT4\nlphar/txP4k1YUyijIW29KE9kg/gDJaZWq+7TRSrKt4LOoOatnQlCRdxReh1T1zhRHwKtKsXq3E1\nRf1Z+Whcb8d1DJ+xI9od2IqnCdGo+heiFW9z8nux6uYksZp8szK9fmjij3kFc4Qh1+EqtsX9vFhZ\n0a4hXM/yK3ip9ldjiyDbExIK7McxrMJK7MSLGCvT62/Yi0FhyJuxu6zqafw9/AAXoGZsQrg4pwAA\nAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$\\frac{517}{670}$$"
      ],
      "text/plain": [
       "517\n",
       "───\n",
       "670"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a + b"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note that the Rational class works with rational expressions *exactly*. This is in contrast to Python’s standard `float` data type which uses floating point representation to *approximate* (rational) numbers.\n",
    "\n",
    "We can convert the `sympy.Rational` type into a Python floating point variable using `float` or the `evalf` method of the Rational object. The `evalf` method can take an argument that specifies how many digits should be computed for the floating point approximation (not all of those may be used by Python’s floating point type of course)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAAkAAAAeCAYAAAD+QjQzAAAABHNCSVQICAgIfAhkiAAAAP1JREFU\nOI3F0y1LREEYxfGfuoiIrNGgoLsWQRAsrvjGJoN5NQmCyU9hMQiiH8BiMfgNDBbBbjCYLSIIJkEN\nimu4MzD3htHkHhiYM/Ofec48l8sf1JfMW1jCKJZxgJsUHsFh4rfwjvEUmsM3poOvoxvgUtlWUn42\nQPO5rOc4yQG7OFJ+VEkbAYIhTMFAAqxhEpeK17bDbY8RaOI1hE1HPZerl4q96P5vOVjFBIYVjTzD\ndfXAC3bCfBNvis6rJVAbD4kflPnIcIH9aGqVzQWs4wPHuVtgD7cxU9QintEIfkbR4A70h8Uv3OMp\n+CY+caeSfhtjir9mBae4+i1Xr/QDpwIoMrLEH2wAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$\\frac{2}{3}$$"
      ],
      "text/plain": [
       "2/3"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c = Rational(2, 3)\n",
    "c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAALUAAAASCAYAAAAdSp//AAAABHNCSVQICAgIfAhkiAAAAg1JREFU\naIHt2r9LVlEcx/GXokmo/RDDCiLpJ9TSFkhIU39CENRSS7S0VEM0aBBt0RK0t0QQDbZE0NBQ0lKQ\nFAQRhQ0i9BMrC7LhXC+369EsuArxfS+X+/28z32W+5zne855CIL/jJba/U5cxGvMoBenMfGPz9+B\nIXzFdHEdwufwwlsCz2qM43CldhZjWFGXF8EuvMFAcb8er4oPDy+8xrzWinxGenmvV2pXpdn7mL+j\nDbdwCQ+KWju68D688Br2Sl5gJFN/inu5AQtwFN+xJrzwlsED3VIPfSWT3cHHxTykwl08Cy+85fDa\niuvm4vop40xhFTqkpvxPtGAfHmEQB6Sfh34M43F44TXolQxIM/VwPcC1IuvLZDl6C/85jlfq+6XV\n6e7wwmvQK9lbDBiqB9LCcQYbM1mOvsL/hpW1bBy3wwuvQa9ki/lf6pEi685kOdoLfyyTjUotTEd4\n4TXklVt6E8WAtZkBnfggs7E9Dz8wiXeZbFraNuwJL7yGvPKlnpIa7U2ZAdvwJFNfiFGsy9RnF5uT\n4YXXoFdyHm/9fnS+VZrBT9Tc7eb2NVUO4UvNaZFm/BvhhdewV7KhCI9Uapelw5fqMfkgfkr71/PR\nioc4VakdlL5J/eGF16RX/0PTHlyQThe7pB7lpLS6nGUn7uOmuTN4lR7pOLNT6odacA4vwwtvCbwg\nCIIgCIKl4hcZmODN5R0YMgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$0.6666666666666666$$"
      ],
      "text/plain": [
       "0.6666666666666666"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "float(c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKsAAAASCAYAAAAkLS6kAAAABHNCSVQICAgIfAhkiAAAAohJREFU\naIHt2k9o3EUUwPHP1sYgTayGSrRgDW1soF48SIVYitBS8eapUFCE9qJePNR4KB6SgvRWhNqQkwhe\ngiA9VIRS8NCDhqBoabBQEFFSSkjxL6mNQuphZsPkl8km9Vb6vrD8+L33ndk9zL59v5klCO4RWo37\nIZzCz7iDbRjB3P+cfzdG8TcW83UUf4UXXuG9jAlcLpylYvw0xssJt2IWrxaxE5jBg+6ePfgFw/n+\ncfyUP2R44ZXecak41l5LeAk2FQPelRblZBGbkKrtMXfHZpzDaXyVY13owW/hhdfwBrFDWn8PSL/4\nLezDGVzQ4BrON4O4gi8r8U4cxT94JLzwNuB9WIn14As81Ez0SiX3bGXQBfyxzps1uYgfwgtvg16N\ncTxXBjbn61P5+mdl0AIeRrfU+K5Hu3xPYz8OSd+SAYzhu/DCK7waL0gt6je15LBUWccquU9yrr/D\n5CXbsn8VbxTxF6Wnv2fCC6/wanwrLeoqz+eJRyu5yZzb3mHykv7s37a635jF5+GFV3hNDlinddhp\n7cV6Pud6O01Q0JX9mUpuSmolusMLL3tNPsNHlfjy1tVcnvjRirMFv1u90bsW/2Iev1Zyi9L2RF94\n4WWvpEvaU71RGbO8WBekhvfJijOI72uDOzCFxyrx9kPafHjhFV6bvVJxvFkZs4KTuG7lEewuqeK+\n1XCfVtn/KjiCWw2nJVXoT8MLr+G1eV1ab29Wcit4Ik/yWhH7QDoUKI9b90tHYKtOFQo24Wu8U8QO\nS9+kgfDCU3/aH5EWa/XEtPlHlmfxvnSa1SP1FG9LT29thnBJaoSbFbekTzpm2yL1Ly28hx/DC6/i\nwSv4GAetsccaBEEQBMF9yX+OWajLMlZ+XAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$0.666666666666667$$"
      ],
      "text/plain": [
       "0.666666666666667"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c.evalf()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgkAAAASCAYAAADR7E2JAAAABHNCSVQICAgIfAhkiAAAAuJJREFU\neJzt3E9oj2EAwPHvb7ZJm7/RUFiMFRcHUaOliNyclCLFBRcH5iCHTclNCmsnKZel5DCppRwc0CJE\nlJKItCZ/G0bh8Ly/9ezds98ah3eH77e0fs/zeZ+57e15398DZmZmZolKuc/NwCngFfAHmAu0Af3/\nuP4KoB34DgxlP9uBrzqdTqfT6Qpz24Au4FFkfkfX9wGd8YIzgTfArmjsGPAEqGXirQReAy3Z5/nA\ny+w/qdPpdDqdrjh3mLAZkPr3G9gKUBVdcJRwM9AdjXURdhf2MbGqgavAaeB2NlYD1AMfdTqdTqfT\nFeqagMWEv/tTCE8WSsAG4CzQS67nQE9+EHgM3EyMV2ov8BOYpdPpdDqdbtK5c4mxeuA6MC0/MZ2w\nxXA+cVEv8HmcX5bvBvBUp9PpdDrdpHSpOoE18UB19nNJ9vNL4qJBYAYwlfBiw3iVtyv6gFZgC+Hu\npBHoAB7odDqdTqcrzKVaT3gF4V5qsoWwk9CRmLuUzTVUWDxubuafAfuj8Y2EtypX6XQ6nU6nK8yl\nuk+4mUi2Llu4PTHXnc0trLB4XEPmfzD6ucYb4JpOp9PpdLrCXL5NjPOIYilj3yT0ZHPTKy0QVZP5\nJ4m5u4RHFlN1Op1Op9MV4vJdAS4kxoe/AtmfLTw7YeqAT4w+qGGsfgEDwIfE3BDh6xZzdDqdTqfT\nFeLiaghnIrxLXDN8kzBIeKFhUcI0AQ9TF1foLjAvMV5++XFAp9PpdDpdYa7cWsJmwPvENSM6Abxl\n5FHNywg7DAdzdjmJ71FG7QS+5UyJsCNxWafT6XQ6XaGu3B7C3/kDibkRLcgW2R2NnSEcplQbjbUS\njmzsrbBWFXAHOBKN7SDcwTTqdDqdTqcr1JVrI9wkJE9WLuU+rwZOEk5frCc8uzhEeCuyXDNwi/Ci\nQ36HIW4O4VjIOsJzkhJwHHih0+l0Op2ucAewHbgIbGaMMxLMzMzMzMzMzMzMzMz+o79JJYrUztlF\nmgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$0.66666666666666666666666666666666666666666666666667$$"
      ],
      "text/plain": [
       "0.66666666666666666666666666666666666666666666666667"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c.evalf(50)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Differentiation and Integration\n",
    "\n",
    "SymPy is capable of carrying out differentiation and integration of many functions:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAC4AAAANCAYAAADWgVyvAAAABHNCSVQICAgIfAhkiAAAAjFJREFU\nSInt1EmIz2EYB/CPJbsYzBQag2xzsE5ZU5amXCQ5GHGwlZCyXS0pakS2Usph4mK5KTWluEjIQbhQ\nimwRjaVkH4f3+eX18x935bm8z/N+3+d9v++z8Y9Kp5I9CTvxFp/QGSdxK/Bp2ISX6Ir+2If72R2L\nMQNt6I5B8c7GwLugEa2ZTwNWoB3DsRbr4v6h2BXvfcPD8idm4j3mZHun8Dj0hUGwOsPr8QiTM/ty\n6d4mtGT2MvTJ7NE45lcQW/Ag+MzCD2wLbFWZdKcgdbG0fwjn4qHX2Fx2xBHcDn0p7qFvhvfGwcze\nWvI/HmcKOY8bodfiAAaGPduvIIHpUpr2VCBWEGrHggrYhsAaMASv8A6npbLKM9QbW0r+dSX7GfZ2\nwKMKa0g1TKoreNqBw8hYv1XAvsY6Cs+lPjgjldxRPJHKg1SzH0r+jzO9Xvr8lQ54fEBNTvx5rFUd\nOLyItaYCVqTxJSbgs9RYtRiGszghNWqb3+u7LPPxBdeyvZGZ3g9vcuLXpGjPq3DZYlzCR4ytgDeE\n71VMkZqxkCdYLTVY/7ijc4b3xH6MD7sRd+JcwW97dn4irpcJNEojcFG2Vy01DywPgoMzfITUtHPD\nXillL6/rOtzM7BXoEfqS+FQTxuGuFIBCdkijtZA1hVKe41OxW5rjL6S0N0vNRurq9YF/Ry8cjgcL\nUnUYIAWhXYp0sxR96CZltlWa8ftF+uPt4+H7BRekbMOYePOPOf5f/stf5CcLWnXpNnC/hgAAAABJ\nRU5ErkJggg==\n",
      "text/latex": [
       "$$\\cos{\\left (x \\right )}$$"
      ],
      "text/plain": [
       "cos(x)"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sympy import Symbol, exp, sin, sqrt, diff\n",
    "x = Symbol('x')\n",
    "y = Symbol('y')\n",
    "diff(sin(x), x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAAwAAAASCAYAAABvqT8MAAAABHNCSVQICAgIfAhkiAAAANxJREFU\nKJHN0r0uhEEUxvGf9VVgfUSjEAWip9Bq3QMXsBeg0YvWfShF6xZIqHQ2G7I0QrYhsop3XjnenC10\nTvPkPDP/M5OZhz/WWKPfwikeMMQyjtDP4Hn0cBC8Y9xhKgNO8IyJ4C3hE50MuMdF4t/iqm5aReew\niW4CPGKnCawVfUuAAdqYjkC76McIABYi8FV0mACTRccj8JJsrGum6HsE+mX64gjgtQkMcI3VBNjA\nTd20wsIldv2Oy3oZcp7ddaUcfRi8M9XH/UQjxuAJe6qIbGNWFY19+XP/l/oGEdwlpDR2XsIAAAAA\nSUVORK5CYII=\n",
      "text/latex": [
       "$$0$$"
      ],
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff(sin(x), y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHcAAAAXCAYAAAAxzdDQAAAABHNCSVQICAgIfAhkiAAABIpJREFU\naIHt2WmolGUUB/Cf5pK5ZtkN09KrUtLqFUwsKko/VEIL+SmpoED6YEULlYJLZUIl7UYUcctIwcKw\nJJKyDDKK0rYPIZW0mGVhabiW3j6c9+0+M87NZu7c8Wbzh+Gd5/9s58w573nOeYY6Dll0qcEewzEZ\nu9GAV7GuBvvWUQPcn3zvghcOliD/N3StwR6X4JTsewu212DPOtCtqN2I2diFveiN2/FjO/Z4HGvx\nEH7DY+1YqxKMwx3ohSH4ALOwsWjciZiPb4QTHo3b8FPNJC0P4zENO4VuvTAPn5UaPBy/4PKEm4pP\n7O8E5aBBhOKvsQnnV7hO9wrmNGElBmTtPngHmzEsGdcf3wt9c8zA5+hRwb7loBK9xmA5Dk+4hdiG\nM0pNeBlbFIbqXuItvqYCAaAvluGITJC54u0dVsFaT+G4MueswMgibox4M5ck3Dxh8NSJB+IPXF/m\nnuWiEr0eFDpMSbjJGfdITuSG7IGL8SX2JRN2ijB1RZmb55iE1dghnGS2CNPjKliru/K9/FyswjEJ\nt0442MSEm4L38WfCbcEXCn/AjkAleq0Tb+nWhOubPXfkRG7cgcJrd5VYaKvKjEE4S3GYOEz8kLXA\nBnEs9C7id4uoRPwoo/Btifk/YGyHSVc5nhNHycqEaxJ50uKcyMPQz8LiaQzPMRiDsrG5Z48V51OL\nCLHXicN9gAgxs/EVPsVrWCDOtJ54Q0SDWmC8MF6aEA4WBn87a5+QPbeVmL8d/YTcuzPu3+peS4wQ\nR+d0kSPth2dEQpVebBwrwnSL1tA2Co8m45qxHhNwVjb+lmpKnuwzrArr3Cs8fELWniD0m1ti7KKs\nryFrd4TuzSrX69JMnvW40z9cSg3KBk3L2t1wjyhjWnBUxi9UGOaWag2zQ/FAMraaaNZ+4zbid6FX\njjOFfnNKjF+S9Q3O2h2he7P269UDb+HddP9iSx+JG0Q83yEyuZdwssh4W0QYS8PqxkzAme0UMMez\nOL0Ef7wIr3tK9F2Ljw6wbk+R3K3BzQnfKMLoXPsb+BWRhfYTTtEe3TtKrxznCQO/qIwk8Du82Ubf\naGHwiW30VxPN2ufhi3BXCb63CKcPl+hbhV/bWK9aujcrX6+TcFoR1y+TZ5+o5w94/ThI3OosbaP/\nAuFxaxKusUxBa4E54siZlXBXZc/torQYWmLeSHzcxpoHS/d+Qt61IpHKsTd7dhEVSYFxbxKF/JCE\nu1pr6CHKh/twataeJDLivLbqiluroEA1MVXIdXcRf3byfYU4e9NjaoQweO7YnUX3PSIf2qAwqozO\nnh/K6t/0RqaPEDQvd8aIu9XLtNa/FwkF1orbm0aFhfRMEf46C84Rtzmv4/mE7yZCWI4nRK4xVav8\n08X149NZu7Povkv807ZZoXFvFFHo7xu11LgLRCI1X9SG/UWq/V4yZrV4i8dmn/Eig3xSeNTyovEH\nG8vEBc2VJfrSjHmTSEjmicuAPtm8C7UmOp1J9xmirl0sXsYGcaPWJI6f/xyaVafO7WxodmjqVRaa\nVPYPSmfHoapXHXXUUUcdhfgLPygJ7YHucZMAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$9 x^{8} + 20 x + 3$$"
      ],
      "text/plain": [
       "   8           \n",
       "9⋅x  + 20⋅x + 3"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff(10 + 3*x + 4*y + 10*x**2 + x**9, x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAAwAAAASCAYAAABvqT8MAAAABHNCSVQICAgIfAhkiAAAAKVJREFU\nKJHFzzEOAXEQxeEvQiQiah2lqBxCpRKVC4haotloqFxDVCpxAkqn0DqBQjQUttis/a8tJF4zycz7\nzZvhx5ojSjZKOeYWVqgWBRaopZshYIRj1iALqGOAXVEgwjqQ/AH0cMMlBJRT8AyTkDmdMMUGjyJA\nE12c8szJk/ro4JCYVeI69v5ti33esjaeWGadlKVKqgbV8P7lGifcccbwG/gnvQCC1RSAi+XGQAAA\nAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$4$$"
      ],
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff(10 + 3*x + 4*y + 10*x**2 + x**9, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABUAAAASCAYAAAC0EpUuAAAABHNCSVQICAgIfAhkiAAAAWxJREFU\nOI3l079L1lEUBvCPIZaYJggh0WAZUos/GkIkqsGxoaUtok2aXGsootJFUDDoH8hBcRMcLCgQhAih\nwc2lKQgjKqOs0N6Ge8Pb8X3VpakHLpf73HOec873+1z+AerCuR9D2EBjXiNYCXHncCvfH8cr3MXb\nWKAPczhUcI+xjt6CO4unaM3nw1jEGjqi6AQquFpwlzM3WXDzOFWloQqm4UBx8Tp39bngmvP+reAu\n4jmOhtxPGIydVsMYNtFTcCv4gRMh9h2+7iXYife4GfgmtAfumDT+i1piV/AIq7htp0OqYRRbGNgr\nsCFXXkLbLnEn8QUP91EcXJLGmq1xfxAvMV5L4DS6A9eSRX9Jfox4gvu1BFukV7Qp/aA/aMqiFRwJ\nOfdwJ3DX2fbpT9TjDT4WQWfyvuxv/17LuQ+C6HlZCL5LnlwLosOS90pbXZBe3wKmCr4+T7QDN6Sn\nNoVnmEFXiPlg+5PEFTv/H/Eb8ppODjbNSu8AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$32$$"
      ],
      "text/plain": [
       "32"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff(10 + 3*x + 4*y + 10*x**2 + x**9, x).subs(x,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHkAAAASCAYAAAB/yXHQAAAABHNCSVQICAgIfAhkiAAABHdJREFU\naIHt2VuoVkUUB/DfUdPUtDJTu0jmJbOg1LIiSnyI6CEiiALBRHrpAl2IAo2UI6X50oWCHsKHQxYK\nEVTmQz5UFJVUZKFQSSGGRaZlWVZmag9rPs+43d93Zp9eIs4fNvubNWv2f82smVlr5mMA/3t0VcqX\nYTGG42x8iGX4tqbteejGHziQ3t34NdO5ArenuuHpWYEt/bS3hLNUbzoeww4cwVg8iF1tuEdgEy5q\nU78Kr+KLxHkubsAa7OyHfaW+aMJrNjbilFQ+Ce/gB0yq6F6Ab3BlKk/A9mRoC7PwGk7MZM9iH2ZW\nyQtQwlmqd7IYgAWZ7CFsxdAa7jn4SEyGdjhSeQ5haT/70cQXpbxgA6ZWZLNSw3WZbAi+xH2ZbCJ2\n495M9mRqe3Mmuz7Jnm5nRBuUcpbqrRADNiSTjcFB3JnJZohx6RGruJOTd+A5vILHcfG/6EepL0p5\nj+I3McPGVeR7sScr34a/9M6ydliIX3BtJpufDF3VR9sqSjlL9bZhfY18C95s06ZHZye/3Qcn5faV\n+qKId1D2ezvGY2RF54CICy3Mx1f4uY9vPy+2xY2ZbLbYTtb2ZVgFpZwleqMwTQxiFd/hkoa2NUFp\nP0p9UYR8u7pCDMD3mezMRPZ2KnfhKpEEzBWr9CQRJ5ZjcweuKViEu/FZAxtLOUv1zknvfTVc+zEa\nw8SANsFQLBEJ3GHR38Vi12hiH2W+KOXtEyvFymslCWPFlvU57sj05onM8MKab9yIZxLpEsdn9H2h\nlLNU78qkt7yGa02qG19T16Pzdv21iK8tLBCZ+oSG9rVD1RelvB0xOZE/msnGJ0P/dPy2sROvd/je\nULyF93BaiQENOUv1Lk963TVc61LdmTV1PTo7eXBN+Xe9Sea/Gbs6X5TytsUwkU0+UZGfkAzdWtNm\nk9jihnX47rzU/qW+DOgHZ6neZO2dvD7Vjaqp69HZyXXYkR4N7KuinS9KeY9JvHKsFgnT/RX5QZHu\n/1TT5oBYrWNS+XzHXxx8kt43iXhUglLOUr1dYrBPrdEbKZKi6uVKX3gH79bIB+vd+puMXY52vijl\nrXVyt4ifyzLZwuz3Jpxe066VrOwWyctm4dQpmc6h9O5y/DbTCSWcpXr7k20Ta/Sm4tMGdrUwS/3q\nHytbUYX25ejW2RdFvFUnL0iyRyryq7Lfa0WGmseVLrFyX8Pf4iw4RBwF9mZ6M9L7Y3GGbmGazkeD\nEs4mehtEbM6TwCnC8U1CSQtv4JqKbJZw3gv96AdlvijlPYq5Yia9UHnWOfZcOwgf4IFMdktqOymT\nrRQ3O/lArhEH/UsrvIeTwe1Qylmqd4bYlm/NZE+Jy5C6a016k7IRNXVzRN9aMbVL3BO879g4W2pf\nqS+KeHMH/Kg+JhBZXX4fOkYkAiNFrOnCwyKdz7EI14kZOl7Eo6WOPcNNF7HlZdzVhr8JZ6neTHG9\nuU3kB2PE1WJ+qT9ODOJZeo84e0TytBovZrpX4x7xZ8NoMWFWiGy6qX1NfFHKO4ABDGAAA/hv4x+9\nY5raTM2izAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$263.66015625$$"
      ],
      "text/plain": [
       "263.660156250000"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff(10 + 3*x + 4*y + 10*x**2 + x**9, x).subs(x,1.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAABHNCSVQICAgIfAhkiAAAAQNJREFU\nOI3t0k8rhFEYBfDfMONvkUhkbY00SvMB1JRsfACyo5SSfAQs7WYpGytlYWFrZzFrSWxkoZSibFAW\n9069M71TM2+TlbO55z7d5zznnnvpMHIZekqYxgyqGMQSdvHYrtgQNiJfwU3kJ5jIYE4feiI/wH4W\nkWaoohj5cK2YluEsNvGGAsawhQ8sC/md4x4D+MI2jtME17CDMp5jbQ93uMA65uO+Hz/4jANeGp0t\nxmmlRG0BlxhvfvN6JB1eYU54sRy6cYszvLcqWEMB36i029iIrriORkcPnRJ8Fa6VTzkzidUs4ke4\nVp9rEacYaVUk2ZzHIabwhF7he1SEfP/xR/gFfr8o7W8nzkUAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$e^{x}$$"
      ],
      "text/plain": [
       " x\n",
       "ℯ "
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff(exp(x), x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAE8AAAAbCAYAAAA9K9JnAAAABHNCSVQICAgIfAhkiAAAAtJJREFU\naIHt2V+IVHUUwPGPq8u6VLuJS6yJJCsLhqaFbLEOhKi9BItBmgZB/gkCRR9M6mFbCnpYXA0fRKG3\nxIeSqEAKiZ4KEXyQUB+kwCCielkJFEVLWh/Ob5irzTQ7u3d2dmK+cOH85nd+53fu4f7OOfcOLabM\nnEY7MIO0YQ8603isgb40HUNYkuTPsWa6Btuma6CJWIZXk3xVKZDl6Edv3T1qIjrwSJLP4PH/0D2E\nh6oZnJeDU83CnXQV8B1+r6DXgbm4mcbPYS2609oP8H1dPZ2ldOHdKjpbsS7JD2M0M/cKbmFx7p41\nAW+iPV0bK+gcU+pCVuEfkS+J4E+IIP6vKGA7juA1Eagv0Jfmt+I6xvEnVpaxsQgjmfEccWyLwVwh\ngvdMvq43li7sSvImnE/yCbVVzQNKwS7HSXxYHMz2grFX6ciU4zw+wV/ixmAQXyb59Rr368PPFeZ2\n4g+8U6PNpuICBpLcXcO6AeyoMPeiCB7Mx9IpeTZLGcJ+cVN/i4IA+2qwMabUB2Z5XqSE3nS9JJ7u\nXI/tGpGoJ8RNvCGS9qOitL8nOvsiT2O3SN7t6BHvnjemsHePOHJDGBZBu4VTk1zfkXx4cO8+fOXf\nQa3lia5KP44qVaWP8ZNoLgui3L+V0d+Oi+7vl94Wyb4RbMH6Bu3tuPtfZz5TqnhLcBgL03hQHK1C\nRv9ZfI3H6utmRbK93aTJLlgtnpjJGvlBKcE+gV8yc78lW8Nl1n0j+qQTaa+5uIJPRR8203SJdDFa\nTXEmeFLkvXIdfDvu4qMZ9ahO1OOT1AbRd53L/FZsPBeKJ+3qg4uakTyC1ynK/FNp/AIuiWpX3ONA\nksfF0SxX5Rdhcw7+NBUvi2q6DctxGWcz8yNSX5QYE590srl1QLwhLKirpzmTx38YPSIg19L4fVF9\nb4vjexrfZvTn4aBoU34VPdaPIg/ezcGfFi1atGjRYnZxD5j0bK2ZCv1/AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$- x e^{- \\frac{x^{2}}{2}}$$"
      ],
      "text/plain": [
       "      2 \n",
       "    -x  \n",
       "    ────\n",
       "     2  \n",
       "-x⋅ℯ    "
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff(exp(-x ** 2 / 2), x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The SymPy `diff()` function takes a minimum of two arguments: the function to be differentiated and the variable with respect to which the differentiation is performed. Higher derivatives may be calculated by specifying additional variables, or by adding an optional integer argument:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACoAAAAWCAYAAAC2ew6NAAAABHNCSVQICAgIfAhkiAAAAgZJREFU\nSInt1kuITnEYx/EPCfPOKEWjDBlvlFlYINPE0BSzkSUrExvFwo4dIbcFYqGUBR1RlLKbxIYsRC7l\ntiFNKXJNcinXsfj/T44zc2beObMYyq9O5zzP//f+n2/nPOc5L/+IRo00QEZLMA0VdOAELo8kUJHe\nYF28Xo1PaEgXx4wEUYE60JOJx6rhiVdwb4D1VpzHBdzHcTSVRuyrM9g+mGkhbqK3YH0+LmFijBtw\nFa/QPEzAVmwT+rNSZGpBNxJcHwC0G7NyuXnRf3aYoKk24rZMjxYpUQz6EU/RmMu/E16IMmrDS8yM\n8ZxYf1VqGF1i0x5MQX0u/wV1JfaD73iI5zGu4hvupoYyb30bJuBFJjdVgL+S8y5Al3B3mrEeG4T+\nbsIOPMEtoS834SfasRKPB4NJFD/6/rQPP7Aok5uNI36PmASPomdxBNo8hBr9KlE7aBUfsCeXP+rP\n9jiHG/F6Og5iUnnEoERtoOOECXGon7UZufgZ9g4Pq68StYGewq4afC1xv+Vlgcq89al2Cj2X/YKs\nLfAuw1dcy+SqQylWFrQr/nZ3Lt8ez3XYj7kx7hQ+yZ8zdbcMpWDReBofz5XM5qmW4jAu4nRur7Rd\nVkSQO8I8rOJ9xrtVaJtSaozFH8SCvXgt/Cdck/G9zaznj/QOTxbm4oF41OMkjgkjq7Ms5H/919+q\nX3qRalZuRKZYAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$12 x^{3}$$"
      ],
      "text/plain": [
       "    3\n",
       "12⋅x "
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff(3*x**4, x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACEAAAASCAYAAADVCrdsAAAABHNCSVQICAgIfAhkiAAAAcRJREFU\nSInt1c2LT1EYB/CPaaRpRimiMBkTCwsLL03yk82YxMofMFkpf8BYKDXEmAUaiX7YiFgoWVKsZCGE\nQlkoGzUlETLeZjJmcc7N6br3uvktWHjqds/zfZ5znu99Xs7lH5BZyXobzuAxvuAbphP7fTTjug97\n0YGl0TaM8VYJDeFHyTONrdFvLW5iXtS7cBuv0dMqidPoxmy0JXgDJxL9Glbk9q6JZC+3SuJUAdaF\n60LaM5nASyzM+b7Dm1ZJFEkT63PYU6FflufwV/j0J0HaK2wNoSwPcvgGzI1BM1mMRbiV812HQaFU\nPdiF3UI/LcF+vKgi+FD9RhvFd2xMsJU46ecEnsfz6NMQmn2o6tB+PKtJoBcfMZLDm+hM9Cu4F9fd\nOIb5VQdfxbkaBObgLsYKbMty+jgO1zgTYUQnam64iIM1/FYJfbGlyNhWgPUJafzduB0QajycYDtL\nfPsxiTsJ1ltFIruIvlYQGIx7D+XwTfHdgSNYHfUBPMHnJO6ebFPRiGaX0GQJgc04jhu4lODtQsph\newzyCFPCV39IfPcJpSyVHXjv10sqk7fK/zFZZhYIjX00Pp24gLPC2A5UEfgvf1VmAPacXe8k/uXU\nAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$72 x$$"
      ],
      "text/plain": [
       "72⋅x"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff(3*x**4, x, x, x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACEAAAASCAYAAADVCrdsAAAABHNCSVQICAgIfAhkiAAAAcRJREFU\nSInt1c2LT1EYB/CPaaRpRimiMBkTCwsLL03yk82YxMofMFkpf8BYKDXEmAUaiX7YiFgoWVKsZCGE\nQlkoGzUlETLeZjJmcc7N6br3uvktWHjqds/zfZ5znu99Xs7lH5BZyXobzuAxvuAbphP7fTTjug97\n0YGl0TaM8VYJDeFHyTONrdFvLW5iXtS7cBuv0dMqidPoxmy0JXgDJxL9Glbk9q6JZC+3SuJUAdaF\n60LaM5nASyzM+b7Dm1ZJFEkT63PYU6FflufwV/j0J0HaK2wNoSwPcvgGzI1BM1mMRbiV812HQaFU\nPdiF3UI/LcF+vKgi+FD9RhvFd2xMsJU46ecEnsfz6NMQmn2o6tB+PKtJoBcfMZLDm+hM9Cu4F9fd\nOIb5VQdfxbkaBObgLsYKbMty+jgO1zgTYUQnam64iIM1/FYJfbGlyNhWgPUJafzduB0QajycYDtL\nfPsxiTsJ1ltFIruIvlYQGIx7D+XwTfHdgSNYHfUBPMHnJO6ebFPRiGaX0GQJgc04jhu4lODtQsph\newzyCFPCV39IfPcJpSyVHXjv10sqk7fK/zFZZhYIjX00Pp24gLPC2A5UEfgvf1VmAPacXe8k/uXU\nAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$72 x$$"
      ],
      "text/plain": [
       "72⋅x"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff(3*x**4, x, 3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAFEAAAAaCAYAAADPELCZAAAABHNCSVQICAgIfAhkiAAAA8ZJREFU\naIHt2F2MXVMUB/CfmaJfKJoaRtMaKkpKhqhptfPChDTx0EQmgnhAIvEiLQ9EMEl9Tn0kKoSg1zch\n4kEr5UG14iOSJlSaIK2MVFIUETIxpK2HdcY9c+be23vOkbYj95/c3LPW3vmftddee621Dy00i4Xo\nxGHoQM/BNefA4AKswADeQ29Jvg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jF\n2CZ7ubjW/e+/WP+X2C1SAdEu7VC95uVC2c9DExmXi4/BbeLDxBrR6LfQQgsttFAC/wBGBdD90KBL\nLwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$1512 x^{2} y^{5}$$"
      ],
      "text/plain": [
       "      2  5\n",
       "1512⋅x ⋅y "
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff(3*x**4*y**7, x, 2, y, 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAFEAAAAaCAYAAADPELCZAAAABHNCSVQICAgIfAhkiAAAA8ZJREFU\naIHt2F2MXVMUB/CfmaJfKJoaRtMaKkpKhqhptfPChDTx0EQmgnhAIvEiLQ9EMEl9Tn0kKoSg1zch\n4kEr5UG14iOSJlSaIK2MVFIUETIxpK2HdcY9c+be23vOkbYj95/c3LPW3vmftddee621Dy00i4Xo\nxGHoQM/BNefA4AKswADeQ29Jvgr2YQ8+xrySfIc8puO+lNyPYRFJRTEgIrCjBMeEwtnYi1MT+WgR\nRf0lOAfqDbTV0U/FFw0I78ciHJvMPQu34eSCfAvxJt7BVjyjXNRsTezbkcizk/9vSnBOw3W4EmvF\nmuvifHwmdq4e9mV+e3BHQb5z8S5mJPJ0bMKPmNvI0Bx4AQ+V5Fgkigr04Ss1gnA+1okE+onGThzC\nU3grMe6cGnOa5VuH0zK67mT+qw1saBbXYlDVAUUxKfU8V9hXa93/oqKxEzfmNKAR3x/4DrMy+l+x\nO+d7slgmnAiTFY/sHmHn5EReINZzJvVz4oHEtzhB5Jw0RjClBG8vTsR6UVEvTeQi2InV+DORL8RH\n2MbYEM2DI0QhmalaBW/F1wW4enAUdqV0JwnHbszMPQ9XiyiYi+txg8innbgL29GFtxPeNI5JPXdh\nJU7BS3g5NXazyOVXJPJObMEtaMfpWL6/hVU0Ps7bVSueZGE/qN9D7Y8vi3tFsVqc0s3DGtXcVhGb\ntlhExl6x+GbxhAiGm4zvHD7Hazm4aqKi8aLba8jDeLQgXxpd+B13Z/SPG3vkX8enyfNsPIjjm3zH\nEtGqEG3VG6mxGWIDb2ySqy4q8kUOUbGHSvIdKSr5wzXG5mTk73FPs8Zl0JG8q1M4LH00LxO2NuwD\n0yhSWDZhcw19u8hjZfC06BlX1hhLb9B8kTffL/ieXaJw9Yuquz41tlR0BduaJSvixG7jEzZRZOpF\nYjMYEDnuzpTumjpzL8JfokKOoqvAOy8RGzGS0vWKQGn6JBZx4gZcnNF1i+PxYgE+ojC1YVVGvyT5\nnyIa5gWJ3CeKwXAit4nKmRdzxM1jFNPEDeqDPCT1WpzRpnKqqqGjeACPiPZiRFTLFeLz0GABvt6E\nb4OxmzBJNRqWCSdtwd8i6n5Lzb1dXO3yYgjHpeRBHC6nE9OYJRbypeqd+CcR7ldl5i4V1fF5cfVb\npeqovHw/G38XH/2NRuZMPCsa3tUiYp7Dk6Lt6Su45jPwIR4T1X0zfnFoXEImJNpEwVl7sA2ZSHjF\n2CZ7ubjW/e+/WP+X2C1SAdEu7VC95uVC2c9DExmXi4/BbeLDxBrR6LfQQgsttFAC/wBGBdD90KBL\nLwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$1512 x^{2} y^{5}$$"
      ],
      "text/plain": [
       "      2  5\n",
       "1512⋅x ⋅y "
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff(diff(3*x**4*y**7, x, x), y, y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "At times, SymPy may return a result in an unfamiliar form. If, for example, you wish to use SymPy to check that you differentiated something correctly, a technique that might be of use is to subtract the SymPy result from your result, and check that the answer is zero.\n",
    "\n",
    "Taking the simple example of a multiquadric radial basis function, $\\phi(r)=\\sqrt{r^2+\\sigma^2}$ with $r=\\sqrt{x^2+y^2}$ and *σ* a constant, we can verify that the first derivative in *x* is $\\partial\\phi/\\partial x=x/\\sqrt{r^2+\\sigma^2}$.\n",
    "\n",
    "In this example, we first ask SymPy to print the derivative. See that it is printed in a different form to our trial derivative, but the subtraction verifies that they are identical:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x/sqrt(x**2 + y**2 + σ**2)\n"
     ]
    }
   ],
   "source": [
    "r = sqrt(x**2 + y**2)\n",
    "sigma = Symbol('σ')\n",
    "def phi(x,y,sigma):\n",
    "    return sqrt(x**2 + y**2 + sigma**2)\n",
    "\n",
    "mydfdx= x / sqrt(r**2 + sigma**2)\n",
    "print(diff(phi(x, y, sigma), x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n"
     ]
    }
   ],
   "source": [
    "print(mydfdx - diff(phi(x, y, sigma), x))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here it is trivial to tell that the expressions are identical without SymPy’s help, but in more complicated examples there may be many more terms and it would become increasingly difficult, time consuming and error-prone to attempt to rearrange our trial derivative and SymPy’s answer into the same form. It is in such cases that this subtraction technique is of most use.\n",
    "\n",
    "Integration uses a similar syntax. For the indefinite case, specify the function and the variable with respect to which the integration is performed:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACsAAAAbCAYAAADlJ3ZtAAAABHNCSVQICAgIfAhkiAAAAmBJREFU\nWIXt11uITVEcx/GPS+63oijkXpQ7yTUSJXnQSAnFgyJRU7woooRCKWoeUYpEEm8Uinmgcfc0kicP\nyv1uTDMe1jpmz5mZc/bsOSPkW6ez1n///2f9zl7/9f/vzV9EhzbEzsMQ9MACHMf1EmhqF15hXRyv\nxGf0Shlb1i6KCjAePeN4JX6gd4q4sbiYZcHOWYIiTxLjMuzFxxRxq3EmzzYTG/EV3eNnHx63QV8T\nZmCnkK89Usbci2JyTMEldEvYKvABk0ugsQmbcFfxnJ2BU3m2I6gXUinHsmg7mnTsmFHcTLzEiDi/\ngalYUiRuDU7n2e4Ld/F9wpbL/S8Z9TViOq6ha5wvRQ3GFIjphEfSnZNDqMWkpDE/cBrWClswHBuE\nxO+HwdiNZ6gS8nQL6jBX2LqnBQQsxM0oohCjsB5b8bAlpzE4pqFRnEQ1ZmNOFLWtyEKFOBF/pyWW\nx/WrsUORhlWhoW7COdyO46E4jP4ZhXbDg2ICIl2ETlhZaL1hefMXQq0rBStwoBX+C4RUPJfGeVx0\nXtRqWc1zXuh4zTEWE/NsfeL6dVK08C34rnGhH9l6jaAv7rRwrY/QtWqFg5WjpyC2Psajoc52x0FM\niPPFQpn5kvDbnlHsClxo4VqNUJGe423CPi5+V2lcf3/9YB1WCdvyGLcS13dhVkaxVzQ9D0n2o1zj\nw3cKn4R6/oucwwDhzr6O8z1Cdfgm/PtLuJpB6CCcxfwifuuF7leLgXgj3KDqDGtmphybf+eCbaFS\n2LWSkPVBJg2j8U54oygJ7Sm2uYfsP5bL0r+T/ec//yQ/AXNhbhBcvhefAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$\\frac{x^{3}}{3}$$"
      ],
      "text/plain": [
       " 3\n",
       "x \n",
       "──\n",
       "3 "
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sympy import integrate\n",
    "integrate(x**2, x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACEAAAAaCAYAAAA5WTUBAAAABHNCSVQICAgIfAhkiAAAAeBJREFU\nSInt1U+ITlEYx/HPjP+NhpiFP+nVqymaKJQpo0khNWUxJcnS0kYaG9koSd78WRAbRVGILBQWFmIh\nNsKOhVKUwmIsJn8aY3HO23vcXnnnXnNJfnW797nnOc/zPfc5z7n8BWorMLcXazELfTiI+78DqlXN\nxOHE3oYRLCwTYgW+YUm0OzEWYUpTm1COejl7IsTKMiGyuoBjfxJgJ2qKbfJCGogQMB2L8wSZVACg\nHxXcErplvfA1XheICVbjBI7jOuZgH47gokY3VPFR2Izp1ZnEquIUbmJHJs8QLjcD6MZJjdqexwvh\nQOoTWnJoHAs6g6nYjWeZsae40mzSaXQk9lU8is+LcBRzWwRYp7H627iWjM3GKHY1m1jJ2G9wqMWk\nWc3DNOEEHcVgMrZFKF3Pr4Isi44bc0LUtQfDEaiuGt5JWrr9J5M34AseJO+qOSA24y4+J+/6hR/d\nWBZiRiRcHu1NwmYaSfz25oCo4Hlid2AV7qVOk+N9ICZ5jK/CqocTv/3C0TxevRLavK4apmQh6nXp\nig4fon1A6JZPQllu4E4OiKU4iycxVq+wIbuEli9d7XiLc2UmveTHQ2pQ+BrdZUK8F05gWICX2N7M\ncSJ/v1uxRijD/Aj0cALz/dc/pO9QXFV2AjmeogAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$x^{2} y$$"
      ],
      "text/plain": [
       " 2  \n",
       "x ⋅y"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "integrate(x**2, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADYAAAAWCAYAAACL6W/rAAAABHNCSVQICAgIfAhkiAAAAt5JREFU\nWIXt1luIVlUUB/BfTmOKSaOpOKlNDk4qJuIlpTS7qBWCD4KGSg+mgg8houODEKQIPTSokEERRCpi\n1muRBEHaBZOQKAmhSFGHQMVhCCW8ZPqw9mH2d77BC3wwOviHj2+ftfZeZ+211n+tQy9FXY3tvYBf\ncBU/1dj2HaFPje01YhDG1tjuXYExeLCnnei1eKCGth7CExiKi/i1hrbvGHnJNGM9RmMvPs10rXga\nn+MZdIqLDBHBeRMt2IaXsRvL09mF2CL49x4O40UMSDZbVTaaOszD1+l5Kl7HdRG4VViNBozAJhwX\nvP4vrSvwIfpiLY6WdL+lS31bki/BrpLsSDeyR3EBX2FlJt+Bk6W9S/FwWrfgfV2VtQt/4lnMxP8i\nMAXeKBZFV5yFH3AFr6bDBRrwFI5hGAZmui/RUXLsomp0pF8zPsnkv6NJlG+BxszGOmwU2SKy3IlD\nOI3tKoP4FybnLx4uSmsEronyKbAgGZ6Jc/gHe7Cm5FCBg6ozRmRmX0m2XFeJFY6vy/RNpf1/451u\nbBcYJFVEkbEzuIzXRLT2Z5ufw3kRpRn4TAziHWgXpXO7uHwLfYMo2QKnsvV4PIYDNzl/QVRV1YB+\nJR3MHZiN7zExyVdjFB4XvPtIZLsW6NTFrzLmCKocymTNpT2PSNQoX6wJf2TPAzAF36X/JZmuHSsE\ngRtu3/eb4t/Mp/5oEwElOuXRtKfwfUPp/CTRdasudgqDs+c21IuLSYZyXo0UjeZsJqvX/ZdHd/L6\n0j/B436Yn943AeNEdvJKektwPcdoqaOXB/Q4fCyG6yXBqQliXi0TGR2cdNdFpt4V2XseWzFNfAT/\nKBrPXLwtMn4VP2OxmGlzBeFPYqeYd33xkhgbbbq67mZ8kN59BV/gm8z3J0Xjq5pjZfQRTWXnrTbe\n7dincjAvFNFp6Rl3aofzYsoTbfWEymZxTyHn2CJMFyXYKC55uCecuo/76EW4AVVqk5MPRcu1AAAA\nAElFTkSuQmCC\n",
      "text/latex": [
       "$$y \\sin{\\left (x \\right )}$$"
      ],
      "text/plain": [
       "y⋅sin(x)"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "integrate(sin(x), y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAD4AAAANCAYAAADxL91HAAAABHNCSVQICAgIfAhkiAAAAmFJREFU\nSInt1Vuoz1kUB/DPYXKXuwwdB7k+YDjFIOXSKSlJHhAPOEpMUxgP8zJIUcelMSmlFPGg4Y2UUrxI\niNzmhVLk1hEZlFzneFj7N2f379/pX/4Pim/92uu292+ttddam28UNVU86ydswr94i3Y4gCuZzWT8\nimb8gJ7YjtuZzQJMwQt0RN/k5y9J3x4NOJ34eixDC4ZgFVanswdhM+5iFD4mumqYileYkckO437G\nzxMB9stkY3APEzL+bMnZi3Eo45egW6JHYK/WCzyEO8mfafgPv2V7V1QSTKWoEQGdKpH/iWOJ7oZn\nWFdm/1+4nuhF+AfdM31X7M74DRm9L+kLHMelRNdiF/pk+ulak/w/xuNacqKS72Da97Mos61lgiqw\nKNnMKaNbm3T1GIineIkjoi3yCumK9RlfV3LWI2xrw49eaCT6rMANZbJRAYak9WEbNsPS+rGM7kNa\nh+OqmAO/Y67o3Z2iRI+Kvn2d7c1baYxI3Lk2/HiN/sQA+lI8TmuvNmyepLV/GV1Ris0Yh3diONVi\nMP7GfjHoXmjt71LMxntcyGTDSmx64DnVCfyCuO1ZZXQLMAAn8UZM1lLUp/3nMVEMswIPsFIMqZ7p\njMLnztiBsYlvwM1kI9ltLPnXeFysLKzK0CCesPmZrJ8YPgWWigB/zGRDxdCbmfjlooLyvq7D5Yxf\nhk5YKBKyGKNxSySvwB/iWczRWBDVfMcnYYt4x5+Ikm0Sg6rAdKxJNp/QBXuS00RQdegtEtkibrpJ\n3D50ENV1Rdz48yTfIhL9VpT8CZzJ/j0y/bOq7/h3fMdXjs/pp4GcT53tkgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$- \\cos{\\left (x \\right )}$$"
      ],
      "text/plain": [
       "-cos(x)"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "integrate(sin(x), x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADQAAAAbCAYAAAAzgqwIAAAABHNCSVQICAgIfAhkiAAAAiRJREFU\nWIXt10+IjVEYx/HPjLkN4U4izZDSlRWJNDSmJFmpyShMShksFLGQWKCUhYxkZWEpC1lgQ9bsZmFh\nJYuxITZTamQKExbn3O7LvNfMe9935pbut049555znvN73vOcP5f/jLYmz9+O01gU6yNN1FIIA1gT\n7UfYmtdhe14HOVmHw9EeUwsujfXonnNFOenE0mg/x6p/9L2JxTM57ChAVB6+xdKPF/hYp18nFuBr\nrG/HDnTFsdfwck6VZqCMyzP0GcKuaC/B9UTbIUxideHKGuQkSrHsqdPnjtqJvAk/hf1H+CC/hMDm\nnH4M4zaOCOIfoxLbhzCBcXzGxhQfPbiSqLcJKVcNcIMQ0JZipU+njBPR3ofRaN+T7bQ6r/YB0riP\nW9VKI4fCGbXlTmMUD/A9TgZ9eBLtoxnnq+Bdnbbj+ISLGX3m5hV6o92VYVwvjtVp2ysEBAuxtiFl\nGRjAuTjRD2HTw9kMPkbU7qkkO4V07o5lUMiC1JTbjFPCJi1hhfDe+pJBiDiuIgR2SQhkEg9nOb4z\nzv/3vBU8NT3Q1JUfxmt/nukXhE093xzE7jwO+oTU6E/8tg3PsDKP4wZJ3j2zJplyV4U0G8R+4anx\nRng8TuTXl4kyPgj3S0OUMIW7RSlqFtW/D8uFFRlropZCqAY0LqRV2qnXgwPzpqhARoQneHIj9gq3\n/bKmKGqApPgO3BCO7PfCPfBW2FdT8y+tRYsWLQrgN3iVTPr4uikaAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$e^{- \\frac{x^{2}}{2}}$$"
      ],
      "text/plain": [
       "   2 \n",
       " -x  \n",
       " ────\n",
       "  2  \n",
       "ℯ    "
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "integrate(-x*exp(-x**2/2), x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can calculate definite integrals by providing `integrate()` with a tuple containing the variable of interest, the lower and the upper bounds. If several variables are specified, multiple integration is performed. When SymPy returns a result in the `Rational` class, it is possible to evaluate it to a floating-point representation at any desired precision (see [numeric types](#Numeric-types))."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAAsAAAASCAYAAACNdSR1AAAABHNCSVQICAgIfAhkiAAAAF5JREFU\nKJFjYKAC4GJgYLhEjEJTBgaG0wwMDP/RJViQ2JoMDAw9DAwMrxkYGP6S4owF2ExmIsWEUcVUV8wB\npblwaRRjYGDYycDAcIUBEnv/GSBRv5+BgSGaFBfQGAAA/84M5lOscPUAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$1$$"
      ],
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "integrate(x*2, (x, 0, 1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACsAAAAbCAYAAADlJ3ZtAAAABHNCSVQICAgIfAhkiAAAAmBJREFU\nWIXt11uITVEcx/GPS+63oijkXpQ7yTUSJXnQSAnFgyJRU7woooRCKWoeUYpEEm8Uinmgcfc0kicP\nyv1uTDMe1jpmz5mZc/bsOSPkW6ez1n///2f9zl7/9f/vzV9EhzbEzsMQ9MACHMf1EmhqF15hXRyv\nxGf0Shlb1i6KCjAePeN4JX6gd4q4sbiYZcHOWYIiTxLjMuzFxxRxq3EmzzYTG/EV3eNnHx63QV8T\nZmCnkK89Usbci2JyTMEldEvYKvABk0ugsQmbcFfxnJ2BU3m2I6gXUinHsmg7mnTsmFHcTLzEiDi/\ngalYUiRuDU7n2e4Ld/F9wpbL/S8Z9TViOq6ha5wvRQ3GFIjphEfSnZNDqMWkpDE/cBrWClswHBuE\nxO+HwdiNZ6gS8nQL6jBX2LqnBQQsxM0oohCjsB5b8bAlpzE4pqFRnEQ1ZmNOFLWtyEKFOBF/pyWW\nx/WrsUORhlWhoW7COdyO46E4jP4ZhXbDg2ICIl2ETlhZaL1hefMXQq0rBStwoBX+C4RUPJfGeVx0\nXtRqWc1zXuh4zTEWE/NsfeL6dVK08C34rnGhH9l6jaAv7rRwrY/QtWqFg5WjpyC2Psajoc52x0FM\niPPFQpn5kvDbnlHsClxo4VqNUJGe423CPi5+V2lcf3/9YB1WCdvyGLcS13dhVkaxVzQ9D0n2o1zj\nw3cKn4R6/oucwwDhzr6O8z1Cdfgm/PtLuJpB6CCcxfwifuuF7leLgXgj3KDqDGtmphybf+eCbaFS\n2LWSkPVBJg2j8U54oygJ7Sm2uYfsP5bL0r+T/ec//yQ/AXNhbhBcvhefAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$\\frac{x^{3}}{3}$$"
      ],
      "text/plain": [
       " 3\n",
       "x \n",
       "──\n",
       "3 "
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "integrate(x**2, x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADQAAAAbCAYAAAAzgqwIAAAABHNCSVQICAgIfAhkiAAAAotJREFU\nWIXt11uoT1kcwPHPcMr9UnToHPeoUSOhkcaQXB6QF16ElDJNeZgUD6QQM+TSaJpSZsJfFEXzMiRe\n3CJSEkpNTU1TI4zJTIMaZvCw1t/Zs89/7//+n5vofGu39/qt33Wvtddam/eMrm3kZwf+wa9t5O+t\nMg0PMKMGm4XtkwpdWmnfF+NxtwabD7G8lXEzaW1Bn+H7Gm2W4GhGX0/cyrGdjB9wGrexH401xs9k\nAT6Kz+cVn3I30KOC/GNcx6sMu4k4i/6x3RsX8RAjCsbOpMH/p815xQqajMMp2VicQglXZRd0CqNT\nsglR/1iB2LmswHqsi9c9fIf5Vey+wdyc/pLsgp4Iq2h9Sv4Yj6rErZlfVB+hrsL3UZejU5Jd0G1h\naxiZkt/H03Ij7XwSlkWnI7ASnwvzthGb8HNCfwi+wGCsEeb1yYyEZuIS/s0sJ58p6BMLKNOAQcKU\nb8YYfIsPYruEn/AJpuJlTLqlHIx+8ijJHqFKbMN/Qo7N2IteifZxXIvPQ7EbA2oIlqQ7bmp6WVmU\nFC9oFP7Gl1kKw1Pt3/BVQefVWITtBfRKihXUTVgRvy6awNjoeHZRgyqc0LRn5VFSrKDD2FKpI+uk\nMAvPcSUhG1UgUCX6YRjutNA+zWbh296YkL3ZE8sF9cBOjIvtOcIS+yyht7aFCSwSjittwbKYy9aU\n/NPyQ3nZnickfAMvhNH4K2GwQfMdviiLhTNfEbrHe09NL7PMdOzBGRxJyOtUmKYDcQC74tULh7BP\nWMrnFEwozWBcqKJTH5O8ExN7hd9xDksTen8k+tNXesTajdVY1VHBOoLLwuh3GK39H8pjNP7UDgfH\nPNqzoLwfuXeSH4XDaieddPIO8RopXHumE7HpygAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$\\frac{x^{4}}{12}$$"
      ],
      "text/plain": [
       " 4\n",
       "x \n",
       "──\n",
       "12"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "integrate(x**2, x, x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAD4AAAAbCAYAAAAkoDzBAAAABHNCSVQICAgIfAhkiAAAAy9JREFU\nWIXt12/IX2MYwPGPZ2N/Hn8WmseGzdPUhGSyxCxhCe3FzIvFUoqUF/7N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uQmCC\n",
      "text/latex": [
       "$$\\frac{x^{4} y}{12}$$"
      ],
      "text/plain": [
       " 4  \n",
       "x ⋅y\n",
       "────\n",
       " 12 "
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "integrate(x**2, x, x, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAAkAAAAeCAYAAAD+QjQzAAAABHNCSVQICAgIfAhkiAAAAQlJREFU\nOI3N07EuhEEUBeDP7gYRW2+jsCqFQmOjINkoVJtoiEai9RQSNS+g0aESjUokJCoJEcV2shohEoVG\nRGys4p+JPyNZKpzqnrlz7zkzc4cfoCcXV9HAKyo4wGVasJ4U70RSyCXmMBbiDp5jopjbVMAeypjA\nNh5SuUqQaOEeM+mGMvYxgH6s4QnDeblGWDxFGyehsIRmNH6N8aR7EWfxqBGLqOEWfTjHUerrvyAa\n7/yuHExjSPY0dWzhOC14xHKIF2SjMkj2NhF13OR4b6L0BbtYjaSUJGuYxQs2unWBFVxETxGTslGt\nBj4qu+B5Pj9CG03cBT6CN1xJ3C/J5vwdU9jE4Xe+/gofYvUtY+Wotg4AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$\\frac{8}{3}$$"
      ],
      "text/plain": [
       "8/3"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "integrate(x**2, (x, 0, 2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAeCAYAAAAl+Z4RAAAABHNCSVQICAgIfAhkiAAAAThJREFU\nOI3t1D0vRFEQBuDHRxRCRxSIj0L0EiGxyWpo6GgQFAqFxh8QpUIvRJT4CaKgpCCh0NJJhIKESBCr\nuEdy3ezeXbZQ8DZn5sy573nvnJmhTFQl/Hps4xgPidg0RtGFQRwlyeawjBzaE7FZrAS7HS9oKKQq\nSVCDW7TF9jo/jepCLDH0h9vaMIAe7OGyVAUTYS8T/DrcowUqS1DwmcyTsD7iGSOlEpwFBfEXy0n5\n/XyvcIDhYDcGVc3JDyexFgh2sRCLtWITi9gQ1cE/AirCmvtVFWWhIiWWEdV7LbLYwuF3yO8wE+xx\nPIka6QvS2jmLq5hfI11xKnawlC9QbKD0YkjUvqs/vR3mcSpPDgqhDzfoCH63qNjGkgcLDZQ3XOA6\n+J14xXnyYFpWp9CEd9EwXcd+Ue1/EB+awTWrPnDugwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$\\frac{16}{3}$$"
      ],
      "text/plain": [
       "16/3"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "integrate(x**2, (x, 0, 2), (x, 0, 2), (y, 0, 1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAALUAAAASCAYAAAAdSp//AAAABHNCSVQICAgIfAhkiAAAAoBJREFU\naIHt2k2oVVUUwPHf9aOHaBHy/EAKnooJOVIoRFQaOXQYBuKgUTQoEAcGKU99iiMHDaWRCoooIjgx\nJ6KgDweKKBWBRKGQqRlk5QeZg3Wub3s813ffQRBk/eFw71r3fzZ7sPe5a+99SJLXjE4t/hCbMQ3v\n4AK24kbL9t/DMP7Fg+pzGH+ll15LbzeO48fKmY+12I/rtfYsw3d4u4pn4Ax+x1Bd7oP38StWVPFc\n/Fx1Mr302nr/167/sKUUphTfd+Bz/FnF9/AlLorZsU7/TMEx7MG5KjdVTJS76aXX0iMG/knMxjXs\nw2U9uFfdMLuWv4vbvW7qwad4aOypn156L8OD0304T7lirEYp+Q1/T6QhnML36aX3kj36GNRl+bEc\nb4pB3GUe5vTTUEEHK8UiczXWiL+RIWzDpfTSa+F1eQNfYRCPsVBsbvykT3aJQnzFeGLBoCjgf8Bn\nRf4jsYpdkl56Lbwu1/BuEa/HTbGwHJcFVaMj/cgFc6pO3hdbgyXXcSK99Fp4XSY3xP/gG+MwgFGx\nGp0oU6tOXm34bVTU7QPppTdB70X8Ul1gUg/pW7FnvXGcxpp4hFv4o+G3B6ImmpleehP0iHOTsw3e\nZPHER/OgHhZF99Yit6HBexGjmNWQH6g6eiu99Fp4S8VmRp1BxZO6znpsb8jvrcWLPF//lHwi6pzS\n6YiDncPppdfSOyIGcMlSUb5s0cBqMSMO1K5DOFjzHotTnV5MwnlsKnIfV+0PpZdeS+8D8Y5Ht8bu\niBPFc0XumRea7hirXeqMGJsJi0Vtc1Qcq/diplhoThd1Uwdfiy2Z9NJr663CF+Jlp7fEoeFOsXuS\nJEmSJEnyKngC4sDTbyU9knoAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$2.6666666666666665$$"
      ],
      "text/plain": [
       "2.6666666666666665"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "float(integrate(x**2, (x, 0, 2)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "sympy.core.numbers.Rational"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(integrate(x**2, (x, 0, 2)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKEAAAASCAYAAAAzD75tAAAABHNCSVQICAgIfAhkiAAAAlZJREFU\naIHt2k2ITlEYwPHfjBmTZpQmX0ka8lHspEloUkR2VkqJYoON8lEWaDDJyoYmSbJQpCYbKWxkwTSR\nRJSSEpHBKONjyIzFuW9z5859Z+a1oNzzr9t7z3P+59y7ON1zznNeIpF/TFWm3Iz9mICZ6MIhvP7D\n/uejFd/Ql/y24nP0CuGtw2k8TDn9qfZdaE93uBg3MCkpN+A23qFJ5SzESyxLytPxInnJ6BXD24OB\nMlc/1kJ1qsFR7MSnpNyLXZiC4yqjBldwAneSWK0wsHuiVxhvLmZhPMYJM28VVuAkrsvQK4zsqZl4\nD95n5VHYih8Gv6rRK6Z3KifWgGvCkm8Yj4Q5e3Ym/hZfRnlYlpt4Er3Ce3m0Y0k6UJO6X4qJwqAr\nMQPTcKuCh5Q+t11owRph9DfhMB5ErxBeHsuFJeC9EZxhHMMvg4vPsTBZWHg+xfZUfKWwa1oUvUJ4\nedxX4SZ3TtJpWyWNhC/nAL4bPu+/wtXoFcLLskqFU3gdOoXdT6XUCi/5OKeuU1h31kXvv/eydOBc\nTnxIiibNWSFnuLtM/Uj8RDc+5tT1Cdv1xuj9916aWiEn+CanTe4gbMUz4aSkxOa8xiPQKeQXs9Ql\nL9odvUJ4JZpRb4ypvk04khM/kynPUybPk7ARXzNOlZAIvxy9wngltghT+I6cuiG0CCP4Qua6hIsZ\nr19OtjtFNe5ibyq2Iem/KXqF8UrsEwbhtpy6IX9g+GD4XF6iDQeT+wXCmXKHcMxXjkZhY1MvrCOq\ncADPo1coD9bjPFarMEcYiUQikUjkr/Ab1mh2KChaNJ0AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$2.66666666666667$$"
      ],
      "text/plain": [
       "2.66666666666667"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result_rational=integrate(x**2, (x, 0, 2))\n",
    "result_rational.evalf()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAf8AAAASCAYAAABVXNdWAAAABHNCSVQICAgIfAhkiAAAAtFJREFU\neJzt3E/IFGUAx/HPqq8vooGIlUTIW2SB3SRELERIDG+eAiEM7FJeBDXwkPL6B+nkRZEIEQ9CIYiX\nCLRLeMiXl0KiKAgiiETR1MA/ZdGrh2cWx3nnfXVjN4h+X1h255nPzO5th3lmhpRSSin9r+o0lpdj\nB+bgaYxjFy78w/0/j1H8jjvV+yhuxMXFxcXFxfXdrcMH+LpmJmrbj+NwfYfLcAbzq+V5OIvLGNF7\nS/EzVlbLi/BT9SPj4uLi4uLi+u+24e4Urwm8BjNqG+zFZvxWLd/EFjyO9/XWLJzCAXxRjQ0pBxTX\n4+Li4uLi4gbinsNizMZM5Qx/B6/gIE5rdFM5oniiMX4dvzbxQ9qEP90/ixAXFxcXFxc3eHeoZWwe\nPlWm9Cf1jTI38Exj/BJuPeTLmn2G7+Li4uLi4uL+VdfWYbxUH5hV+7wCjyl/9t2ewpP4vIcv6Z5e\nGMcqrFWOOkawG+fj4uLi4uLi+u7aelmZ4v9yGjOp/fjb/YsLHqWFyoUF3+Pt2vhq5WrEF+Pi4uLi\n4uL67tr6So8X7T9b7XRfLxspZwru4g+T5xd+wSdxcXFxcXFxfXfNXtXjVMEwxpSrCnttSPmR37as\nG1OuKxiOi4uLi4uL66trdhJHW8YfuNWv3hHlnv+tU6yfrr9wBdda1t1Rbj9YEBcXFxcXF9dXV29I\nuaf/Yss2rX/+o/hBebJft41tG0/TmPJ8gGbD1Q+9EhcXFxcXF9d312055nrEW/XfwJ6W8Q8by0tM\ncb9g1QbcbpiO8gChE3FxcXFxcXEDcd3eVKYK3mlZ90CrlCOH443Xx/io4Sa0PCWo1gycw/ba2OvV\n/kfi4uLi4uLiBuK6vav8+b/Vsk6n9vmqyXMG3fZhZ/X5BeWZ/yeVxwFP1QLlgsG5ynxFB+/hx7i4\nuLi4uLiBOViPY1ijx3v8U0oppZRSSimllFJKKaX0n+oe0wRYMRHlN+AAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$2.6666666666666666666666666666666666666666666666667$$"
      ],
      "text/plain": [
       "2.6666666666666666666666666666666666666666666666667"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result_rational.evalf(50)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Ordinary differential equations\n",
    "\n",
    "SymPy has inbuilt support for solving several kinds of ordinary differential equation via its `dsolve` command. We need to set up the ODE and pass it as the first argument, `eq`. The second argument is the function `f(x)` to solve for. An optional third argument, `hint`, influences the method that `dsolve` uses: some methods are better-suited to certain classes of ODEs, or will express the solution more simply, than others.\n",
    "\n",
    "To set up the ODE solver, we need a way to refer to the unknown function for which we are solving, as well as its derivatives. The `Function` and `Derivative` classes facilitate this:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAG8AAAAaCAYAAAC5KgISAAAABHNCSVQICAgIfAhkiAAABCtJREFU\naIHt2WuIlFUYwPFf21qJ5qW10NYuKpq1mEZorqaEJn6IJSQJS8OipczKMisoCP1S2AX6YBesKCVq\niyIoiIw+RHZTQrCibJPKrlgZFV20st0+PO847w4z48w2O7PZ/GHZc33P877POc/lDHVqzTQ04zCM\nxPTailOnHDagG3/jbYwvdWJjHwlUp3R2YVRS3l3OxLryggax+7trtH5ZSsvwf1FeC5aiFX/gR/yE\nO/A5OrAS39RAtkG4HHsxD/fgg6RvpjCjk7EtGTsfN+LTqktaZYbgYXyBJTgy1XcsnsNGfFx90Q7Q\nKoIVQnmdwhIMEUqF87E1KW8Ugc2BSYciY/CiOGFt+CHPmInYgfVYVsG1r8W4Iv1bxWknrN/+pHwy\nPsMUocQu/Im14j3WVlDGfssx4uV3YvhBxn6EC/tcovxMx684KqlPEn73tJxx2zA1KQ+tjmi1o0N8\nhLkljH1DmNBaMBqrU/VleDMpt+EGcRr/woCkfUVmcNpsjk0Gj8ETeDLVt0pofrGwy5tSfWcKf9Kd\nLNSOKzFMJJ+rZU3DJ714wXI5C1vwOmaXMH6xeN9SmYLlIugZgBG4Gr+UJ+YB2nAKDscE3ILvcJn4\ntp0YKPLA34Wf/jb3IQ/iCFyH93L63sXTuAiDU+3jsU52E2wQzn+GiJS6hOIlwhTiUWwv8++cAs9a\nLzbS0iLr9ZZLxbdoTrXdLAKKmnE2Lk7KL+HZVN8wofXl4mSmeUCErxmekY2KThBhb1NSn4UzKidy\nQXYK5Y2u8HNbhfmamWqbJoKi4yq8VlmMFGF0s1DUglRfm/gYLSIXSnNSTv1r3F5gjeGyoW9fslcE\nAaWQexV1tNi4J+YZ+7IwZ3eLTXkvrhAhfb9gJX7WMx+6C98LxbYXmXuqUPK5BfobhT3va3YrLdlu\nwH2pejvWyPruNAOEz17/78WrHLk3LPPxqriFyDAbm4WDHqwwc0VO8laqbazsTcBQ+XMtIpEu16Su\nwmt52rfgPGHOfysy/yo8lao/kvxfnWdskwgoqhFw9ZoduDNVHyQUkglP0z5voDiVk5L683gn1d8g\nfGKGOTi9ksIWYJYw/SuKjJmHWwv05Tt5jcIi5ZszCgvLE7Fv2CROQYb7xctMTupLZBPKC0Q0uUjc\nVLwvcqYMtwknn6Ea/i7D9cLvXSI2UYamRK6biszNpzxio27WM72aiscd/CKgT8i9HpsozMd27BM5\nU4vIZbpEKjFHKHmEeKGMKVwjTto+cVpfwCtJ3wRxGqppdmYIJY7DHpGHfYWH8GGRed0i192V094o\nrFIzvhRxQafwg/v1MxqE83+s1oJUmUInr1/ToWdyvkCcopJ/2T1E+E8qb4+4LYHjRZS4qHbiVJ3F\n4papW0Sh19RWnIOT9nkLxY1Bg4ig1omwu06dOnXq1KlTp6b8A4tc2L4EpXpSAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$y{\\left (x \\right )} = C_{1} e^{- 5 x}$$"
      ],
      "text/plain": [
       "           -5⋅x\n",
       "y(x) = C₁⋅ℯ    "
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sympy import Symbol, dsolve, Function, Derivative, Eq\n",
    "y = Function(\"y\")\n",
    "x = Symbol('x')\n",
    "y_ = Derivative(y(x), x)\n",
    "dsolve(y_ + 5*y(x), y(x))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note how `dsolve` has introduced a constant of integration, `C1`. It will introduce as many constants as are required, and they will all be named `Cn`, where `n` is an integer. Note also that the first argument to `dsolve` is taken to be equal to zero unless we use the `Eq()` function to specify otherwise:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAG8AAAAaCAYAAAC5KgISAAAABHNCSVQICAgIfAhkiAAABCtJREFU\naIHt2WuIlFUYwPFf21qJ5qW10NYuKpq1mEZorqaEJn6IJSQJS8OipczKMisoCP1S2AX6YBesKCVq\niyIoiIw+RHZTQrCibJPKrlgZFV20st0+PO847w4z48w2O7PZ/GHZc33P877POc/lDHVqzTQ04zCM\nxPTailOnHDagG3/jbYwvdWJjHwlUp3R2YVRS3l3OxLryggax+7trtH5ZSsvwf1FeC5aiFX/gR/yE\nO/A5OrAS39RAtkG4HHsxD/fgg6RvpjCjk7EtGTsfN+LTqktaZYbgYXyBJTgy1XcsnsNGfFx90Q7Q\nKoIVQnmdwhIMEUqF87E1KW8Ugc2BSYciY/CiOGFt+CHPmInYgfVYVsG1r8W4Iv1bxWknrN/+pHwy\nPsMUocQu/Im14j3WVlDGfssx4uV3YvhBxn6EC/tcovxMx684KqlPEn73tJxx2zA1KQ+tjmi1o0N8\nhLkljH1DmNBaMBqrU/VleDMpt+EGcRr/woCkfUVmcNpsjk0Gj8ETeDLVt0pofrGwy5tSfWcKf9Kd\nLNSOKzFMJJ+rZU3DJ714wXI5C1vwOmaXMH6xeN9SmYLlIugZgBG4Gr+UJ+YB2nAKDscE3ILvcJn4\ntp0YKPLA34Wf/jb3IQ/iCFyH93L63sXTuAiDU+3jsU52E2wQzn+GiJS6hOIlwhTiUWwv8++cAs9a\nLzbS0iLr9ZZLxbdoTrXdLAKKmnE2Lk7KL+HZVN8wofXl4mSmeUCErxmekY2KThBhb1NSn4UzKidy\nQXYK5Y2u8HNbhfmamWqbJoKi4yq8VlmMFGF0s1DUglRfm/gYLSIXSnNSTv1r3F5gjeGyoW9fslcE\nAaWQexV1tNi4J+YZ+7IwZ3eLTXkvrhAhfb9gJX7WMx+6C98LxbYXmXuqUPK5BfobhT3va3YrLdlu\nwH2pejvWyPruNAOEz17/78WrHLk3LPPxqriFyDAbm4WDHqwwc0VO8laqbazsTcBQ+XMtIpEu16Su\nwmt52rfgPGHOfysy/yo8lao/kvxfnWdskwgoqhFw9ZoduDNVHyQUkglP0z5voDiVk5L683gn1d8g\nfGKGOTi9ksIWYJYw/SuKjJmHWwv05Tt5jcIi5ZszCgvLE7Fv2CROQYb7xctMTupLZBPKC0Q0uUjc\nVLwvcqYMtwknn6Ea/i7D9cLvXSI2UYamRK6biszNpzxio27WM72aiscd/CKgT8i9HpsozMd27BM5\nU4vIZbpEKjFHKHmEeKGMKVwjTto+cVpfwCtJ3wRxGqppdmYIJY7DHpGHfYWH8GGRed0i192V094o\nrFIzvhRxQafwg/v1MxqE83+s1oJUmUInr1/ToWdyvkCcopJ/2T1E+E8qb4+4LYHjRZS4qHbiVJ3F\n4papW0Sh19RWnIOT9nkLxY1Bg4ig1omwu06dOnXq1KlTp6b8A4tc2L4EpXpSAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$y{\\left (x \\right )} = C_{1} e^{- 5 x}$$"
      ],
      "text/plain": [
       "           -5⋅x\n",
       "y(x) = C₁⋅ℯ    "
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dsolve(y_ + 5*y(x), y(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw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16Su\nwmt52rfgPGHOfysy/yo8lao/kvxfnWdskwgoqhFw9ZoduDNVHyQUkglP0z5voDiVk5L683gn1d8g\nfGKGOTi9ksIWYJYw/SuKjJmHWwv05Tt5jcIi5ZszCgvLE7Fv2CROQYb7xctMTupLZBPKC0Q0uUjc\nVLwvcqYMtwknn6Ea/i7D9cLvXSI2UYamRK6biszNpzxio27WM72aiscd/CKgT8i9HpsozMd27BM5\nU4vIZbpEKjFHKHmEeKGMKVwjTto+cVpfwCtJ3wRxGqppdmYIJY7DHpGHfYWH8GGRed0i192V094o\nrFIzvhRxQafwg/v1MxqE83+s1oJUmUInr1/ToWdyvkCcopJ/2T1E+E8qb4+4LYHjRZS4qHbiVJ3F\n4papW0Sh19RWnIOT9nkLxY1Bg4ig1omwu06dOnXq1KlTp6b8A4tc2L4EpXpSAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$y{\\left (x \\right )} = C_{1} e^{- 5 x}$$"
      ],
      "text/plain": [
       "           -5⋅x\n",
       "y(x) = C₁⋅ℯ    "
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dsolve(Eq(y_ + 5*y(x), 0), y(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKoAAAAeCAYAAAC8LYXhAAAABHNCSVQICAgIfAhkiAAABmJJREFU\neJzt23+sHFUVwPEPj5YfVltKixYrUlrBYkGthEKBVgMSEk2jUEKqBaGlwYCCQBHUBH3/GKGWmPgL\nkB/darQaGvwFof7+rYDRiDUFbFDQahBRQhRakfb5x5lxZ7cz+3Zn9+2+R+abbHbvzJ07586ce+45\n596loqKiog0WYTb2wSycOFhxxpyXYDNe2XT8BFyBYXwHS/srVsVo1DCC3fgFjuxh22f1sK1esEYo\n4gjmZI6/GB/LlM/Bs2IAV2QYEhZtEAwLSzqrx+3Ox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ng/CThH401j+OvbdQbElNrlqJ16MnC57u5a+nGls04\npuDcj4Xv2swOdR+5E2r6aFGbI8Mz8AP8J3NsqejkUxr902ZOw3MiGEiZq77aMA3/KLj2Fp27BWvx\no5zj94qU1BQ80+L6i/HlTHmNcBeWC58xywwxTfYjGCzLNDHAfldwfqF8+WdqbVF7xcjoVdrnQVyf\nKU8RyndZUs76qAcKa3tsUv66yAmmDAkfNuVUEb2ONUuE+3JZizqn40MF5/JSJ5PETJN3zaE4uzMR\nx4TVIoIvYrNQyiwLRX/LrE7VDMBHTdkirFvKZ0RH0hWMc9VzfstFVL9CrPBsFemGlGtl8mD645+m\nXC781PM07meYkcj1/hbXFq2arBMzSzZQOV4k5ad3IWuv+La9Y4YsqaypW7cPPi9mwP2LLmpBTfeK\n2vYWx+bocD5uFQ7xLpGTXKCed9tPWMYtybF16tP5sLCgu4QV/obYV0istuzW36nzJKGw8/CkyHPu\nEEuI21pcNyJyyY82HZ8kZpvZ+LN4uQ8LvzUvZ9lPZon04RtHqbdEzDQ7RRC4VQS/ZX3UYd2tHNVE\nGnEP7se7lNiIMiQCkw1dCDIRGW3DxHjkcpE+7Cc13T+nYSW2OG7SmOg/U4y0Xm7knQhMREX9mb39\nz7HmDbpf6x8uc9GTYpUJXi6i9RVdCjIRmWiK+iqx6DARabXFsZCzhc+5Xqz1v9D/u9PMSrGMPCLS\nVu8drDht82ER5E5EirY4VrwA+abW+e3xTDaPP0djhqmiYlzQ7hZH7L1JoaKin+xU34p5ltjwfn1e\nxUH987Kigtjw9GphMI8Se0GeGKhEFRUVFRUVFRUVFW3yPwA0R4G3bZUcAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$y{\\left (x \\right )} = \\frac{C_{1}}{5} e^{- 5 x} + \\frac{12}{5}$$"
      ],
      "text/plain": [
       "           -5⋅x     \n",
       "       C₁⋅ℯ       12\n",
       "y(x) = ──────── + ──\n",
       "          5       5 "
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dsolve(Eq(y_ + 5*y(x), 12), y(x))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The results from `dsolve` are an instance of the `Equality` class. This has consequences when we wish to numerically evaluate the function and use the result elsewhere (*e.g.* if we wanted to plot *y*(*x*) against *x*), because even after using `subs()` and `evalf()`, we still have an `Equality`, not any sort of scalar. The way to evaluate the function to a number is via the `rhs` attribute of the `Equality`.\n",
    "\n",
    "Note that, here, we use `z` to store the `Equality` returned by `dsolve`, even though it is an expression for a function called `y(x)`, to emphasise the distinction between the `Equality` itself and the data that it contains."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAG8AAAAaCAYAAAC5KgISAAAABHNCSVQICAgIfAhkiAAABCtJREFU\naIHt2WuIlFUYwPFf21qJ5qW10NYuKpq1mEZorqaEJn6IJSQJS8OipczKMisoCP1S2AX6YBesKCVq\niyIoiIw+RHZTQrCibJPKrlgZFV20st0+PO847w4z48w2O7PZ/GHZc33P877POc/lDHVqzTQ04zCM\nxPTailOnHDagG3/jbYwvdWJjHwlUp3R2YVRS3l3OxLryggax+7trtH5ZSsvwf1FeC5aiFX/gR/yE\nO/A5OrAS39RAtkG4HHsxD/fgg6RvpjCjk7EtGTsfN+LTqktaZYbgYXyBJTgy1XcsnsNGfFx90Q7Q\nKoIVQnmdwhIMEUqF87E1KW8Ugc2BSYciY/CiOGFt+CHPmInYgfVYVsG1r8W4Iv1bxWknrN/+pHwy\nPsMUocQu/Im14j3WVlDGfssx4uV3YvhBxn6EC/tcovxMx684KqlPEn73tJxx2zA1KQ+tjmi1o0N8\nhLkljH1DmNBaMBqrU/VleDMpt+EGcRr/woCkfUVmcNpsjk0Gj8ETeDLVt0pofrGwy5tSfWcKf9Kd\nLNSOKzFMJJ+rZU3DJ714wXI5C1vwOmaXMH6xeN9SmYLlIugZgBG4Gr+UJ+YB2nAKDscE3ILvcJn4\ntp0YKPLA34Wf/jb3IQ/iCFyH93L63sXTuAiDU+3jsU52E2wQzn+GiJS6hOIlwhTiUWwv8++cAs9a\nLzbS0iLr9ZZLxbdoTrXdLAKKmnE2Lk7KL+HZVN8wofXl4mSmeUCErxmekY2KThBhb1NSn4UzKidy\nQXYK5Y2u8HNbhfmamWqbJoKi4yq8VlmMFGF0s1DUglRfm/gYLSIXSnNSTv1r3F5gjeGyoW9fslcE\nAaWQexV1tNi4J+YZ+7IwZ3eLTXkvrhAhfb9gJX7WMx+6C98LxbYXmXuqUPK5BfobhT3va3YrLdlu\nwH2pejvWyPruNAOEz17/78WrHLk3LPPxqriFyDAbm4WDHqwwc0VO8laqbazsTcBQ+XMtIpEu16Su\nwmt52rfgPGHOfysy/yo8lao/kvxfnWdskwgoqhFw9ZoduDNVHyQUkglP0z5voDiVk5L683gn1d8g\nfGKGOTi9ksIWYJYw/SuKjJmHWwv05Tt5jcIi5ZszCgvLE7Fv2CROQYb7xctMTupLZBPKC0Q0uUjc\nVLwvcqYMtwknn6Ea/i7D9cLvXSI2UYamRK6biszNpzxio27WM72aiscd/CKgT8i9HpsozMd27BM5\nU4vIZbpEKjFHKHmEeKGMKVwjTto+cVpfwCtJ3wRxGqppdmYIJY7DHpGHfYWH8GGRed0i192V094o\nrFIzvhRxQafwg/v1MxqE83+s1oJUmUInr1/ToWdyvkCcopJ/2T1E+E8qb4+4LYHjRZS4qHbiVJ3F\n4papW0Sh19RWnIOT9nkLxY1Bg4ig1omwu06dOnXq1KlTp6b8A4tc2L4EpXpSAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$y{\\left (x \\right )} = C_{1} e^{- 5 x}$$"
      ],
      "text/plain": [
       "           -5⋅x\n",
       "y(x) = C₁⋅ℯ    "
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z = dsolve(y_ + 5*y(x), y(x))\n",
    "z"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "sympy.core.relational.Equality"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAD0AAAAZCAYAAACCXybJAAAABHNCSVQICAgIfAhkiAAAAo5JREFU\nWIXt1kuojVEUwPGfyw155dkVA5JHJFeeF5lIRjcTmSDEQEQIZSBGQsxMLgMkMZKJgalHHmVg4F3e\nCREh8rwG67t8Tuee8517znHR/Y/23t9aa6+19/rWXvy7TMUQdEIdprevO3+Gw2jGN1zEyKyKXark\n0J/gAQYn42elKJYbdI047eYy7bSVkoJtoVjQ47AUDfiE13iDnXiI49iAp23ZvEx6YAU+Yi724nry\nbaZI9wm4msjOwybca81gbxzEIyxG19S3gTiJI7hTwSBKpUEUMSLo2yLzeovDgPm4nIyPiIL3UynN\ncJwWN9qIV3lkxuAmmrCqbPd/sRYjCny/LLKLyNKvyXgY7qNeBP8dn7FLxLGr0Kb9EqW76FvEwVtY\nWESmWkzHe3RL5uNFXRmbI3cVU5Jxn9aMHU+U52TY+LxI9fZgKLan5qtwIRk3YqO4/S+oTdbXtQin\n03saLuEcZmfYeBGOleBoPVaLYliLAViDdyXYSNOI0eiMUdiKF1iOSSJju4t3/IOoQ89zjTSJW17a\nRicKsQzXRAfVwhZRaNqVuyLooRW22yDSbGZqbaooloMqvFcm0un9UaRCzwx6I8UhtdALh8S/9ChH\n9gwmiiejk0jHmziBt23yuoI8k63JqMH+1HwldogsGZYjWyuelaby3asOp0Qa9igitwaz8qznC7ou\nWd9SrnOVpCY13pfMV7QiS3Q+fcRzlYWXIoXztbuDsSCjnaqyXjz6S/x+IP2xDZsL6Oa7adiDs36v\nH1NwVPEGqCrka0NniOBHiJt6hyc4gBsFbDWLFvZBznoX7BbP1WPRx98W//lX/zit3fRfR01xkf+P\nzhWwsUi0l5NFcarDlQrY7aCDDjrIxA8Wn3tWLsNniAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$C_{1} e^{- 5 x}$$"
      ],
      "text/plain": [
       "    -5⋅x\n",
       "C₁⋅ℯ    "
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z.rhs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhCAYAAACV1IbrAAAABHNCSVQICAgIfAhkiAAAA4JJREFU\naIHt2VloXFUYwPFfYmuNS+IC2to+SOMSKS6RuFWNokhRNLSIigtSl4eqUKtVEXxTiKhVcSuK0D60\nuIsiqBUfjBsoioIPruib4IahRUqrtvHhu5c5c9tOZiYznWk6fxjOnO8s891zz7ecM3SYlK5WK9AC\nTsdC9OEs3I8PW6pRm3EgHkjqV2Az5rZGnfbkRGxHf1bvxYRYrIYzE0cl9TOwFquz8kWckLTPwc3N\nUKRGuoS55W5mgVikwUb/0D64F/tn9UG8if2SPquxCScnsos06Y1NgXV4pBkT3yq2bc5j4m1cnsgu\nyWRPFMa+qnwxW8kNeEgVwau7xol7MIyvE9lXYtdsTGQHZeXmwviPMFLjbzaDi7PybsxS7jqmzAju\nrKLfw/gPJxXkp2BNIxWqg2HciNnZZzHOrHbwfDyFt3B1oW2lcMaP49xJ5unHH3buqA/HZ9Uq1ATm\ni10/Ufj0Vho0I/l+F24TD3cPnk/arsN3mIc/dzHXYlyARXgUz+ykzzgOqaDPGrHbamEFxqrs+7NJ\nFqQSZyvtnneEg805GNtwC97F0ZPMtS/exyc4rNDWhy/qVbLVzBYObK5YkCVJ26ViSy7AepxaxXzn\nZWNeKcj78cYUdd3t5NHtV2wVeczfeDvpc44wsW/wvTC5lAHlKQF8mZWXiaNAzpDYZXsUMwr1ReIh\ntiayYXEAnMAGXIXXs7ZekQLMxHH4KZNvy8oukXzmnI/RCvo8p/bsdyU+KMgmapyjJr7Fg0n9APyD\n5YnsZbEoRGL4L37EoUmfIaHo54nsSE3KbuukWwSYlEGxcYqWUcYG8TZznhYPm+Y7C3FTUh8VESbN\nXNcJsx1KFLrPFCJLg+nDHUpuIWcjfhfZ+C4ZwMciX1olMuS/7JiZjwhHnrNU5FHr8R5ewrFJ+xEq\nh/5WMVaoX1vrBN3Coa9thDZtylihvkqcO5fv2DV4QfmZbAm24JhGa9ZGjBXqeZAZxfG5MDWjC5Wi\nRO5klwqnvDdwvZIv2iK5D0tTgGU4TWy5OSID/3Q3KdgOjCs97zwRxfdqekRE/k1EuR5haivEDcE1\naefp/G9JN24Xed64iLB15Wm1XrrtSTwr3MmTeE15slsT03UnDYjj0jJx+TdL3GxsaqVS7caVGngl\nM13N7QcRxnO6RIivy3Kmq7kRTnu7OFb1iGvpX1qqUYcOHTo0gP8B4bWcSAAGoK0AAAAASUVORK5C\nYII=\n",
      "text/latex": [
       "$$y{\\left (3 \\right )} = \\frac{2}{e^{15}}$$"
      ],
      "text/plain": [
       "          -15\n",
       "y(3) = 2⋅ℯ   "
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "C1=Symbol('C1')\n",
    "y3 = z.subs({C1:2, x:3})\n",
    "y3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAM0AAAAaCAYAAAAUh9j+AAAABHNCSVQICAgIfAhkiAAABpBJREFU\neJztmnmMFEUUh79dbpAVAbkNIHIqiorGENgQVPAKoiKyqEiIhABBLomCxuDBlagQURCNuAICguhG\no0FNBI9EEo2oIKLgjaigqOCqQHD941edrent7eljllmT+pJJT79+86r6dVe9V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\n0QDamo9OORwOh8PhcDgcDofD4agZ/gOoHdM70Si93AAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$y{\\left (3 \\right )} = 6.11804641 \\cdot 10^{-7}$$"
      ],
      "text/plain": [
       "y(3) = 6.11804641e-7"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y3.evalf(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABUAAAAhCAYAAAA2/OAtAAAABHNCSVQICAgIfAhkiAAAAWBJREFU\nSInt1T1LHFEUBuBn1wUNhBVsLBQMpjGIwa0EA8HaziZp0pg0KWzWvyAoCKZIqtRptRJtI9YhCWkE\nIV3SpDBqIUHEtbgz7GVAGe9ssPGFgTn34z3n3PPFf0CtxJkZzGIQz7CC/SpKH2Itkl/gDCNVSJ/i\nEo8zuYlORp6MmuB+/kyTGWmrCmkRn7DRS8LXWFcuuKUwn5HCAB7ddLivBOFzjGFXyIY5wdpfqRaO\n41QITvw1UwnvkYY85zp3obyOd4W1FhpCf7g1BrGMr4X1E/zRLYok7BXkV9cdbFRQMo1joUDep5Ls\nFeS8xFfxJN6oJypY1H3Lf5jqBelfbGf/o/gRb5bpUg+whAVhtHzHAd4Ik+AnPscX4oZbRxvnmSXD\nErt87P5HIRs+YAtDKYR0LZ3AN7zFBfqxKfTSZLzElyoEMXL3D4XUyFET0iZpyMWX2kJ0j4SI7+B3\nCuk9eo8rz/M23+UELt4AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$\\frac{2}{e^{15}}$$"
      ],
      "text/plain": [
       "   -15\n",
       "2⋅ℯ   "
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y3.rhs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {
    "collapsed": false
   },
   "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SbhI5oCxbcb5YSoeKxTgLN4oVbDaW4xi8kNhsL2g/OinT\nvNZNIgTnzeqUKpqU8VeXuWJL8GqLfqro01bSQfZXchM7cmz6xLF3/P64gRJ04R79aQpieV+MRSLp\nOFMs83v1HwyyjBab910izzULawfpt6wmZf3V5afkPr5q0U9ZfdpONk+2zsDEZkq6GSyaCfuTo8Ve\nIU/kp0TYGiUG3nocn2N3ggitRC7nJJHcTUnDxXyxt3pOrBxlNJlfwV8dPhf7wlYpq89+ZYE4gh6W\nqesSI/zlBtvpDXZF9GotT9aFH8RJr5GxInSlYes+fJe0SZmW+F1U0HeP/LxWFU3K+MvS68Dnyerq\n0zaG4X3xzS3lCjFbezJ1c/EP3izpd5V4iLwMeFm7K8VJLnsf3eK0eXmmbrIYANdm6paLZGPRZ5Pp\nSd8PNNSX1aSsvyxldalKkd+6+rSV8WImrBaJz5X2/bQwQ8T3Jwr8TBSDcKN44L3ixazF1TXsiMG9\nBi8JIVeLdEIjc8Th4HE8jVfEx/U8upO+tiV9/ykG1byMTRlNyvqr8rxVqOK3ij4dOnTo0KFDhw4d\nDhL+BcMTXEfvapXIAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$6.11804641 \\cdot 10^{-7}$$"
      ],
      "text/plain": [
       "6.118046410e-7"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y3.rhs.evalf(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKIAAAAWCAYAAABDqUd4AAAABHNCSVQICAgIfAhkiAAABWRJREFU\naIHt2n3oltUZwPGPmWZmWpvUkImWldugpfaySiZCsShGSTIokuqPSBaabBXkekFrUe1Ni7Bo/fHr\nheVYG27DoIKKYhQ6rFaMSLbhVma5UWkue98f13nweHvfz3Pf9/MzBz5feLh/93Wu+5zrXOftOuf8\nGDDg/4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v6C\n39XIuxtt/dMXnY74FXxDzB77ivvEJuOHfeh9zZ4HtBvSc76IS94So/rwku8Pwbv2dPQoscy/2cO2\nbvY18fEzYhkuMlIs2WW8LTrRxhr5d6ONf/qmEyOeKRpxTZY2Kj0vEHHNA/ofbVUsE0H4zZns4lRm\nXb3xeEHYPd2uGKwzs4wQDfle0ptcYscxeLFEfopohKqjmDr2NfHxTOUx5ERxvljGq/Y8PmrDDs39\ns1eZqjpWOFb5sUQZQ7rHiAtwU4n83oZ6Y8SB60Zx+NrhpFT++kx2k7h6y8+1piW9K0rKuCSlFQ9z\nm9hXxlTlPn5EdLqczgH5cN2uDKlul6b+6Ztud82jCs8Oc8SRxBN2XXF1o3PdNlYE28W8VuAxsUPM\n7fq8od5O/FQsUe9kOkvEKC/emFwpOs+DSbZYXGHdV1KHzkxTFdvVrUeRKh/fnvK7TByTjMAP8Jw4\nxxwOurVLU//sFcaLOGazcOJO4YB5KX26iCNWlX4dHCEa5RW77kq3pnwvyvT+k6UXfze30CPODVeL\nDvEEfo3jSmycIa67VoiNxW/FPyuUMU/ERidVpDexj94+hm/jN2K5XpPyGaM/6rYLzfwzYMCAAQMG\nDBgwYMCw8z+KvbXPXuvphgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$4.122307245 \\cdot 10^{-9}$$"
      ],
      "text/plain": [
       "4.122307245e-9"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z.rhs.subs({C1:2, x:4}).evalf(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKkAAAAWCAYAAAC7SbyPAAAABHNCSVQICAgIfAhkiAAABRFJREFU\naIHt2meIHVUUB/BfbNFkE3vsookVa8SGShAURRTxix8kQfwgNgw2BA0oscSKXRMbspCoETWxYxQ0\nKBbsEhELKhElRkWxxxb9cObxZt/et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d5p4CbuW4JWxryhvF4MTs4na9dS+Lm2+1j4MGA790k46Phujs7RHZPbfF+y/NqyRkM0WMdDFOdmJ\nFfvfX0x6uBJWXbyp0qt8E+2ddFNxYPFxgneHKJivW4JXxr4ivIl4W1QQpuTkf2d/xxgc0hAnbJNw\nxjBjD4dfsvG3Seh2wDsj7L80Op10Ria7rEN+SMf9jgbXJ1NoHQ6sGpJVH28JDu+QTRXhy4Ls/huR\nSO2XaN8n4vD3S/DK2FeE94coon9m4K7V2rXfUE8ZaCg8KWLTfKI2RThut3CjZ8g76TQRb00WL7R1\nLTRwd5omjgUfKdB/62Dgj1HiXS3m0CqRjBFx5Su4JpP9g7PEbrhdru1EESOeLerFRXl1z2OVKJ3d\nZqCTniV2ubrKUK2vwLiEbp7Y6fPHojPFsejdNY1fGPljr8Xi6Gt6gpfP8FeKXeaTAv1/LFZ9tySj\nbt7r4kh0gfhhxkRxSHGKgQ71gMjQb9R2yDWFYyytwKt7HrNwEu4XBfzN8J34fcVHw/Q9FCaJfGMr\n7JbJlms7372ZbIVI1OZkY/YJ3zjK8AuwQYMGDRo0aNCgQYP/Hf4FKCnEjt0qoXsAAAAASUVORK5C\nYII=\n",
      "text/latex": [
       "$$2.777588773 \\cdot 10^{-11}$$"
      ],
      "text/plain": [
       "2.777588773e-11"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z.rhs.subs({C1:2, x:5}).evalf(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "sympy.core.numbers.Float"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(z.rhs.subs({C1:2, x:5}).evalf(10))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "At times, `dsolve` may return too general a solution. One example is when there is a possibility that some coefficients may be complex. If we know that, for example, they are always real and positive, we can provide `dsolve` this information to avoid the solution becoming unnecessarily complicated:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAM8AAAAfCAYAAABAv5lwAAAABHNCSVQICAgIfAhkiAAABddJREFU\neJzt23usZeMZx/GPM2eYydwwqu7loFHSKjImTEbEmJLKpCnqEhrMiLpfRpnWPSRuIS1a6tp9KjK0\nJUjKNP6qNhO0EnfGhLqUEGTaujOMP5617HV2zt5nr3Vm385Z32TnrMv7rvWs3zrv+zzP+76LkpKS\nQqzTaQNKctOHkzA52b+yg7aMBUo9xxELsGWyfTd266AtY4HCeva1xJySVrItDk+2X1J98SXFKPUc\nR6yHacn2g9isg7aMBQrrWXqe7uB7eL7Jsp/ifczB3/Bmq4zqYUo9xxHrYZsc5afjvBbZMhYo9Wwj\nfXpr5PFnmJj89u2wLaOlG7QvpGczRm+Ha/CsaKEn4ssCBnaSnXAU9hBuehX+i0vxKpbiDO132X04\nHrviJjyWHO/HBXhdDKH+AKeJhPZQ3IzPMAFz8UxSbw62x854HFOwH36Ol1v+NMPTTu27Ss91kxss\nxB+wGhuM7vnaynQhzGs4UrjzlG/gHgzixfabBn6MjXE7fpI5fot4ufBNfIxJI1xrOhYl2z/Co8n2\nIDYpYNvEAnVq7Wm39l2l5wKsEcN5u2N+M5W6hG3wHJZjZp0yO4jn+91avvcp+HWDXzo0Ok28pLRH\nJJLdDzL78/FQE/ecJDo7uBy/GNUTxD/+5gXrdkr7rtLzaryTt1IXsCFWYKWRPeULOKTlFtXnBBEW\nTxG9/WIsy5y/HGfL5/Efx6xke0ZBuyrYukC9TmvfNXr+HQ/kuEm3sFT0avOaKPsPEUZ0iuXYRYQV\nE0WI/Pvk3DQR1szGySNcZ4H4R9kan6uGXacWtKuiWOPptPZt07PegMGgiA33E73Dq/h3csP5hrbk\n3URMuya50bFi9GJ94fYvFAnbapE/tZrZeEQ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0wIOZq1tT8pnfSqLwcLWLSu7BjZ00pKSkpKSkpKSkpKSkp\nKSkpKSnpQb4COquH2AjZwNwAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$f{\\left (x \\right )} = C_{1} e^{- i a^{2} x} + C_{2} e^{i a^{2} x}$$"
      ],
      "text/plain": [
       "               2            2  \n",
       "           -ⅈ⋅a ⋅x       ⅈ⋅a ⋅x\n",
       "f(x) = C₁⋅ℯ        + C₂⋅ℯ      "
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sympy import *\n",
    "a, x = symbols('a,x')\n",
    "f = Function('f')\n",
    "dsolve(Derivative(f(x), x, 2) + a**4*f(x), f(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQMAAAAaCAYAAACzfzksAAAABHNCSVQICAgIfAhkiAAACCZJREFU\neJzt3H2wVVUZx/GPvKr4ykuWaMqbQU4YoWAUQQqNQ2ONNgWOlgRmk2lvWmRNpcxESVlpZSqOXWga\nQ6qZHCuarGhs1MwZrSy1V6ysMALMXqCo2x/P3p19zj373nPO3udeiP2duXPvXmvvtdZev7XXep5n\nLaCioqKiYp9mAeYPdSMwGh/BiKFuyH5OpWdFRzwH1xR4fi7ejqvwTbykYHtOxYcLlnEgU1RPytW0\n0nM/4os4osNnD8OHMtevwd8xsWCbbsDsgmUcqBTRk+5oWumZwzAcNNSNSHixEKpTZuI/mJJcH4Fe\nMYCKMB2bCpbRbfYlHVOK6kl3NO1Iz6n4KtbiRtHh+xsni/bfjbtEJ6zDJPE+G3FswToWYgfeUbCc\nz+OFBZ4/SJiU6Udxshg4swq2Cx7C0SWU0ymDoWPZFNWT7mnalp6j8EuswAbsbefhfYAjxGD5DS4Q\nwZOUCfgy1uNnJdR1nhDopoLlbBX9Xhafw7UllXWzzlajkQXrHUwdy2arcv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6Uq6mXdXzNnypxYb8v5Fnuld0To/B7dMlai7uwYNc935L1vRapTZ7nCa22Coq\nyuB6YX4PBumx3a+JY7tnqTf3K1rgYRHomCl8iaL/7HR/43xxpLVXRKcvHdrmVHTAZHGysLfhp8j/\nMnRAslz4YRvFyamKioqKioqKioqKioqKiooDl/8CTaxadSR9zgMAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$f{\\left (x \\right )} = C_{1} \\sin{\\left (a^{2} x \\right )} + C_{2} \\cos{\\left (a^{2} x \\right )}$$"
      ],
      "text/plain": [
       "             ⎛ 2  ⎞         ⎛ 2  ⎞\n",
       "f(x) = C₁⋅sin⎝a ⋅x⎠ + C₂⋅cos⎝a ⋅x⎠"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a=Symbol('a',real=True,positive=True)\n",
    "dsolve(Derivative(f(x), x, 2)+a**4*f(x), f(x))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Series expansions and plotting\n",
    "\n",
    "It is possible to expand many SymPy expressions as Taylor series. The `series` method makes this straightforward. At minimum, we must specify the expression and the variable in which to expand it. Optionally, we can also specify the point around which to expand, the maximum term number, and the direction of the expansion (try `help(Basic.series)` for more information)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOgAAAAbCAYAAAB2r8PPAAAABHNCSVQICAgIfAhkiAAAB6tJREFU\neJzt3HuwVVUdwPEPQqKCikaKEnkzVMAcS5KQEC3Fmcb+yEhQMM3EKRtNe/yTZSE9TcscZ2xK00Nk\nMGIvjTKbMXspEWaF9tR0jCyltFSMpKQ/fnt399l3n3v2Ofc8LpfznbnD3Wuvtdfvt56/32+tCz16\n9OjRo23MwmSMwiTM7q44I5LjcGwbvz8Wl2NMG+voGsfidJyDlXhtd8XpOBVsx39xNw7pqjQjj8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+uMhfyESxnV+e/IwTzvrnRTh5fhMVNko7ZZgk\nfMl67CsGwhoR/FglVv1mqGhsQHVb//3wXWECb09+NotBvCST7++Z9/mf/I76CrGTXikCSV9VfP+0\nDBXN+/RnC9NxqzAf14uJlL8NVYtF+n3MdvTTrviA8oHWEcdF4o5jJ6lo/1W/snRD/1ZTMXzas0eL\n+YmBfxzbbo7Sub9oqUc39G81w6k9e7SQqcLM2lnZ2fXfodnRL8uXYbHq4MXOxs6uf49hzq3K/x9F\nI5GdXf8ePXr06NGjR48ePXoMH/4HWQLWSpe7eV0AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$x - \\frac{x^{3}}{6} + \\frac{x^{5}}{120} + \\mathcal{O}\\left(x^{6}\\right)$$"
      ],
      "text/plain": [
       "     3     5        \n",
       "    x     x     ⎛ 6⎞\n",
       "x - ── + ─── + O⎝x ⎠\n",
       "    6    120        "
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sympy import *\n",
    "x = Symbol('x')\n",
    "sin(x).series(x, 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOgAAAAbCAYAAAB2r8PPAAAABHNCSVQICAgIfAhkiAAAB6tJREFU\neJzt3HuwVVUdwPEPQqKCikaKEnkzVMAcS5KQEC3Fmcb+yEhQMM3EKRtNe/yTZSE9TcscZ2xK00Nk\nMGIvjTKbMXspEWaF9tR0jCyltFSMpKQ/fnt399l3n3v2Ofc8LpfznbnD3Wuvtdfvt56/32+tCz16\n9OjRo23MwmSMwiTM7q44I5LjcGwbvz8Wl2NMG+voGsfidJyDlXhtd8XpOBVsx39xNw7pqjQjj8Nw\nWYu+dSY+iKV4b+7dq/DJFtUzrPgbzkp+PxVbML5k2Te1RaLOskzsnJOaKDsS9G83N2OvFnznrfon\nYB+ew8RcnmswswV1DStejnH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SV9VfP+0\nDBXN+/RnC9NxqzAf14uJlL8NVYtF+n3MdvTTrviA8oHWEcdF4o5jJ6lo/1W/snRD/1ZTMXzas0eL\n+YmBfxzbbo7Sub9oqUc39G81w6k9e7SQqcLM2lnZ2fXfodnRL8uXYbHq4MXOxs6uf49hzq3K/x9F\nI5GdXf8ePXr06NGjR48ePXoMH/4HWQLWSpe7eV0AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$x - \\frac{x^{3}}{6} + \\frac{x^{5}}{120} + \\mathcal{O}\\left(x^{6}\\right)$$"
      ],
      "text/plain": [
       "     3     5        \n",
       "    x     x     ⎛ 6⎞\n",
       "x - ── + ─── + O⎝x ⎠\n",
       "    6    120        "
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "series(sin(x), x, 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAC5QAAAAaCAYAAAByp/I4AAAABHNCSVQICAgIfAhkiAAAIABJREFU\neJztnXm8LVV1578PeCDTUxSRSXiCIA6oIBIGeRKVRKOxCe0ARgUjTonz0MkjEq/aRhRREztqJB8s\nxTinG5OYGE3iC7GNGjV2iJ04RiKiBqNGxQHkvf5jVfWtW7eGteusferce3/fz+d93j119tm1p/Wr\ntVftXQVCCCGEEEIIIYQQQoiNzsnAYcAm4GDglGmLI4QQQog1gPwHIcRGQponhBBCCCGEEEIIIcSE\n/AzwHGAJ+BCwbdLSCCHWO2cA5wFPBK4Efnba4gghNgivwPRHCCGmpAB2AbcAfwccM2lphBDCeDzw\nQuBC4HkTl0UIsZoC+Q9RXAd8t/HvDZOWSAjRpECaF8WdgGcATwYuBk6YtjhCiA40H5udE4E3AU8H\nfhc4adriCCHmxDbg+KkLsUbZH3gvcETj+EmYjp4PXA7cec7lWk8cAvwesHnqggghhBCp7Ae8vPb5\nUcAPsSdAC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fDrpNXd3w/73Y/gv43gzaZZz/U+WfgxIRyCiGEEOuGgvGOoxBCpFAg\nvRFCCCGEEEKIRaFAczQhxMahQJonhBBCCCGE2JgUTDsf+gjwcxOeX8BFUxdgDXF/bMOHEEIIsSE5\nEdg8dSGEEBsC6Y0QQgghhBBCLA6aowkhNhLSPCGEEEIIIcRGZer50H2BD054fgEvmroAa4RNwA7g\nuInLIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCHEumI78OSpC7FBeQRw2tSFWCNcBJw7dSGEEEII\nIYQQQgghhBBCCCGEEEIIIYQQQgghhFiPLAH3nLoQG4zdsEXSYpiDscX3QgghhBBCCCGEEEIIIYQQ\nQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEII\nIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGE2ED8P/luY/scAfj3AAAA\nAElFTkSuQmCC\n",
      "text/latex": [
       "$$1.11729533119247 - 0.438791280945186 \\left(x - 0.5\\right)^{2} + 0.0799042564340338 \\left(x - 0.5\\right)^{3} + 0.0365659400787655 \\left(x - 0.5\\right)^{4} - 0.00399521282170169 \\left(x - 0.5\\right)^{5} - 0.00121886466929218 \\left(x - 0.5\\right)^{6} + 9.51241148024212 \\cdot 10^{-5} \\left(x - 0.5\\right)^{7} + 2.17654405230747 \\cdot 10^{-5} \\left(x - 0.5\\right)^{8} - 1.32116826114474 \\cdot 10^{-6} \\left(x - 0.5\\right)^{9} - 0.479425538604203 x + \\mathcal{O}\\left(\\left(x - 0.5\\right)^{10}; x\\rightarrow0.5\\right)$$"
      ],
      "text/plain": [
       "                                              2                               \n",
       "1.11729533119247 - 0.438791280945186⋅(x - 0.5)  + 0.0799042564340338⋅(x - 0.5)\n",
       "\n",
       "3                               4                                5            \n",
       "  + 0.0365659400787655⋅(x - 0.5)  - 0.00399521282170169⋅(x - 0.5)  - 0.0012188\n",
       "\n",
       "                    6                                7                        \n",
       "6466929218⋅(x - 0.5)  + 9.51241148024212e-5⋅(x - 0.5)  + 2.17654405230747e-5⋅(\n",
       "\n",
       "        8                                9                          ⎛         \n",
       "x - 0.5)  - 1.32116826114474e-6⋅(x - 0.5)  - 0.479425538604203⋅x + O⎝(x - 0.5)\n",
       "\n",
       "10         ⎞\n",
       "  ; x → 0.5⎠"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# NBVAL_IGNORE_OUTPUT\n",
    "cos(x).series(x, 0.5, 10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In some cases, especially for numerical evaluation and plotting the results, it is necessary to remove the trailing `O(n)` term:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAACskAAAAXCAYAAABDXTPeAAAABHNCSVQICAgIfAhkiAAAIABJREFU\neJztnXm0JkV5h5/BGWBgGBRHGDYZQHADFVQUEA5RSTQSg0RUDIFxScSF4MZRVPSiUUHiFhM1cg62\n4AHXBBNNjEl0XGIMblE0UdwVEcW4K4uC+aP6O7dv315+Vf3W131n3uecOXO//uqrqq7lV2+9VV0N\njuM4juM4juOMyRHA3sAqYCNw/3Gz4ziOkxXXPMdxHMdxHGdeuO3pOI7jOI7jOI7jOA6rx86A4ziO\n47RwGnBH4DpgV+CV42ZnxXI4cAbweeBg4BLgU6PmyHGcOk8BTgduBa4k6J+Txv7ACcBNwB7Ae4HP\njpojx3HquObZcQ2wrnbtcuDJI+TFcRxnhs/lHceZEm57Oo4zBhcQfFIfHTsjjuNslRwD7APsBBwH\nXAx8aMwMOY6z4rgfcBTBb3M08BLgI6PmyHEcx3EcZxtlM3B++fcm4GZgw1iZWcHsClwPHFp+3h34\nOrDdaDlyHKeJBcKJNhtHzsfWwIWVv1cBl42VEcdxWlnANc+CjcAzgQMJDwh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4\njuM4juM4juM4juM4juM4juM4juM4juM4juM4juM4juM4juM4juM4juM4juM4juM4juM4juM4juM4\njuM4juM4juM4juM4juM4juO08//mQcOnqGt/bAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$- 0.479425538604203 x - 1.32116826114474 \\cdot 10^{-6} \\left(x - 0.5\\right)^{9} + 2.17654405230747 \\cdot 10^{-5} \\left(x - 0.5\\right)^{8} + 9.51241148024212 \\cdot 10^{-5} \\left(x - 0.5\\right)^{7} - 0.00121886466929218 \\left(x - 0.5\\right)^{6} - 0.00399521282170169 \\left(x - 0.5\\right)^{5} + 0.0365659400787655 \\left(x - 0.5\\right)^{4} + 0.0799042564340338 \\left(x - 0.5\\right)^{3} - 0.438791280945186 \\left(x - 0.5\\right)^{2} + 1.11729533119247$$"
      ],
      "text/plain": [
       "                                                    9                         \n",
       "-0.479425538604203⋅x - 1.32116826114474e-6⋅(x - 0.5)  + 2.17654405230747e-5⋅(x\n",
       "\n",
       "       8                                7                                6    \n",
       " - 0.5)  + 9.51241148024212e-5⋅(x - 0.5)  - 0.00121886466929218⋅(x - 0.5)  - 0\n",
       "\n",
       "                            5                               4                 \n",
       ".00399521282170169⋅(x - 0.5)  + 0.0365659400787655⋅(x - 0.5)  + 0.079904256434\n",
       "\n",
       "              3                              2                   \n",
       "0338⋅(x - 0.5)  - 0.438791280945186⋅(x - 0.5)  + 1.11729533119247"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# NBVAL_IGNORE_OUTPUT\n",
    "cos(x).series(x, 0.5, 10).removeO()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "SymPy provides two inbuilt plotting functions, `Plot()` from the `sympy.plotting` module, and `plot` from `sympy.mpmath.visualization`. At the time of writing, these functions lack the ability to add a key to the plot, which means they are unsuitable for most of our needs. Should you wish to use them nevertheless, their `help()` text is useful.\n",
    "\n",
    "For most of our purposes, Matplotlib should be the plotting tool of choice. The details are in chapter \\[cha:visualisingdata\\]. Here we furnish just one example of how to plot the results of a SymPy computation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fd934bf6898>"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fd934bf6898>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from sympy import sin,series,Symbol\n",
    "import pylab\n",
    "x = Symbol('x')\n",
    "s10 = sin(x).series(x,0,10).removeO()\n",
    "s20 = sin(x).series(x,0,20).removeO()\n",
    "s = sin(x)\n",
    "xx = []\n",
    "y10 = []\n",
    "y20 = []\n",
    "y = []\n",
    "for i in range(1000):\n",
    "  xx.append(i / 100.0)\n",
    "  y10.append(float(s10.subs({x:i/100.0})))\n",
    "  y20.append(float(s20.subs({x:i/100.0})))\n",
    "  y.append(float(s.subs({x:i/100.0})))\n",
    "\n",
    "pylab.figure()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x7fd934ed2f98>"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEPCAYAAACtCNj2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xd4lFXax/HvCT2kAAkkQEhCJ1KCKF0hgKiLBVkQ9BVU\nlHV1Xd3VdVGxxV5xde0IgthwVURQ6RCaSAs1lFBDDySYkFASktzvH4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TTSNs6uAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fd934e6e1d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pylab.plot(xx, y10, label='O(10)')\n",
    "pylab.plot(xx, y20, label='O(20)')\n",
    "pylab.plot(xx, y, label='sin(x)')\n",
    "\n",
    "pylab.axis([0, 10, -4, 4])\n",
    "pylab.xlabel('x')\n",
    "pylab.ylabel('f(x)')\n",
    "\n",
    "pylab.legend()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Linear equations and matrix inversion\n",
    "\n",
    "SymPy has a `Matrix` class and associated functions that allow the symbolic solution of systems of linear equations (and, of course, we can obtain numerical answers with `subs()` and `evalf()`). We shall consider the example of the following simple pair of linear equations:\n",
    "\n",
    "$$\\begin{aligned}\n",
    "3x + 7y&= 12z\\\\\n",
    "4x - 2y&= 5z\\end{aligned}$$\n",
    "\n",
    " We may write this system in the form $A\\vec{x}=\\vec{b}$ (multiply *A* by $\\vec{x}$ if you want to verify that we recover the original equations), where\n",
    "\n",
    "$$A=\\left(\\begin{array}{cc}\n",
    "3 & 7\\\\\n",
    "4 & -2 \\end{array} \\right),\\qquad\n",
    "\\vec{x}=\\left(\\begin{array}{c}\n",
    "x\\\\\n",
    "y \\end{array}\\right),\\qquad\n",
    "\\vec{b}=\\left( \\begin{array}{c}\n",
    "12z\\\\\n",
    "5z \\end{array}\\right).$$\n",
    "\n",
    "Here we included a symbol, *z*, on the right-hand side to demonstrate that symbols will be propagated into the solution. In many cases we would have *z* = 1, but there may still be benefit to using SymPy over a numerical solver even when the solution contains no symbols because of its ability to return exact fractions rather than approximate `float`s.\n",
    "\n",
    "One strategy to solve for $\\vec{x}$ is to invert the matrix *A* and pre-multiply, *i.e.* $A^{-1}A\\vec{x}=\\vec{x}=A^{-1}\\vec{b}$. SymPy’s `Matrix` class has an `inv()` method that allows us to find the inverse, and `*` performs matrix multiplication for us, when appropriate:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}3 & 7\\\\4 & -2\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡3  7 ⎤\n",
       "⎢     ⎥\n",
       "⎣4  -2⎦"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sympy import symbols,Matrix\n",
    "x, y, z = symbols('x,y,z')\n",
    "A = Matrix(([3, 7], [4, -2]))\n",
    "A"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}\\frac{1}{17} & \\frac{7}{34}\\\\\\frac{2}{17} & - \\frac{3}{34}\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡1/17  7/34 ⎤\n",
       "⎢           ⎥\n",
       "⎣2/17  -3/34⎦"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A.inv()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}12 z\\\\5 z\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡12⋅z⎤\n",
       "⎢    ⎥\n",
       "⎣5⋅z ⎦"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b = Matrix(( 12*z,5*z  ))\n",
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}\\frac{59 z}{34}\\\\\\frac{33 z}{34}\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡59⋅z⎤\n",
       "⎢────⎥\n",
       "⎢ 34 ⎥\n",
       "⎢    ⎥\n",
       "⎢33⋅z⎥\n",
       "⎢────⎥\n",
       "⎣ 34 ⎦"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = A.inv()*b\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}5.726\\\\3.203\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡5.726⎤\n",
       "⎢     ⎥\n",
       "⎣3.203⎦"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x.subs({z:3.3}).evalf(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "sympy.matrices.dense.MutableDenseMatrix"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "An alternative method of solving the same problem is to construct the system as a matrix in augmented form; that is the form obtained by appending the columns of (in our example) *A* and $\\vec{b}$ together. The augmented matrix is[1]:\n",
    "\n",
    "$$(A|\\vec{b})=\\left(\\begin{array}{cc|c}\n",
    "3 & 7 & 12z\\\\\n",
    "4 & -2 & 5z\\end{array} \\right),$$\n",
    "\n",
    " and as before we construct this as a SymPy `Matrix` object, but in this case we pass it to the `solve_linear_system()` function:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}3 & 7 & 12 z\\\\4 & -2 & 5 z\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡3  7   12⋅z⎤\n",
       "⎢           ⎥\n",
       "⎣4  -2  5⋅z ⎦"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sympy import Matrix, symbols, solve_linear_system\n",
    "x, y, z = symbols('x,y,z')\n",
    "system = Matrix(([3, 7, 12*z],[4, -2, 5*z]))\n",
    "system"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANUAAAAZCAYAAACmamtMAAAABHNCSVQICAgIfAhkiAAABr1JREFU\neJzt3HuMHXUVwPHPltpuLW1BqW54WGl5rG8qxqCCoUZMlKAFUYkQ0wCKEBVMUVGivRFRedWoBDUa\ni4ogUhqRIEZ8ARJAFMXGiKjRViSK7xdUBeofZ8b+7t2ZuXO3e+/cxftNJrvze8zv3HPu/M75nd9v\nlxEjRgyMPXAuPoW9G5alSY5pWoARPdFve12Ej+NpvXbcG1tx/ExLNMuYxJeaFmJEbQZlr2fgfhxb\nVDm3pNMr8Ud8vk9CdeODuAZ341/YFy/H53Bv0m451mEbHsZCvAO/nSE5XosrOsoOwSl4EAuy61xs\n7vKsM/EYfGCGZBsm6upkurqry6DstVm8G6dhY13hWvh23cZ9YHvH9TDe3dFmX/xBu7s/AXcpnyx6\n5U5hhJyV+DLGk7JL8DccVPGcZfin0Oujjbo6ma7uemGQ9mrhtqKKOd3lbISt+KTwVuvxbJzT0eZD\nQv7U3V+NA8XLtbM8Fz8WM1zO63BUduV8BYtwYsWzzsZjZ0CmYaSuTqaru7oMjb2G9aX6Jd6A1Vgr\nvE/KPByJn+ORpPxBbFES6/bI8bi8o+wHYpb7a1K2KPv5QMlzjsE3Z0CeYaWuTqaju14Yenu1NBv+\ndRt7QoSFNxXUfVcsIneGXfAj9cLIC/AQnlVQt6vInhLytnZSrtlClU6m064bTdirZRrh3/aKuoNF\n+LUem/A4vBPn4TKsKOl3AO7L+lYxL3veRUIJ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1wrvu1UkVF4i4uuU4/D6Erm2ifXm/fhzUn66ONJyakk/4gxZ+jNnldho3CTW\nBv1mi/Yv2PmZTDeWtO9mr7o66UV3w2yvlJ7D5ZbiDdg9RCr7guxaKLImnxBx6RFdnjspUuPdvNlh\nYiH5WeF+zzF1Nl+QybBBeLcb8LyONou0p//PEjvstwoPkTKh/MuVskbs6VyWjXml9j20lMXC498n\nZr5t2dirs/qnivXMr2qMOxNMitT0xWLWvxl/Ur5mqWuvNerppFu7YbdXSkuJpyqjpdkTFU1whvK0\ncr9pNTDmHHGaf0MDY88ETdqLWXigtglehS82NPb87k12miu0b/q+QuxRvX8AY/eDJu1VSdlL9Q87\nDh7+P7Af/iJOaAyaVfj+AMY5wo5waU9xBGyNWMjPNpq0V85uIlNdm73EAvGkvogzfLzHzPy5SK/M\nNbizgceKxMSFYjP1kAGN2w+aslfOwWLd9dJeOy4RRrjUo/9/VFyrePNxxHDSpL0+LBJz+zc0/ogR\nI0aMGDFixIjh4r/AsP+iG7cDZwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$\\left \\{ x : \\frac{59 z}{34}, \\quad y : \\frac{33 z}{34}\\right \\}$$"
      ],
      "text/plain": [
       "⎧   59⋅z     33⋅z⎫\n",
       "⎨x: ────, y: ────⎬\n",
       "⎩    34       34 ⎭"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sol = solve_linear_system(system,x,y)\n",
    "sol"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(sol)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x = 5.726\n",
      "y = 3.203\n"
     ]
    }
   ],
   "source": [
    "# NBVAL_IGNORE_OUTPUT\n",
    "for k in sol.keys():\n",
    "    print(k,'=',sol[k].subs({z:3.3}).evalf(4))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A third option is the `solve()` method, whose arguments include the individual symbolic equations, rather than any matrices. Like `dsolve()` (see [ODEs](#Ordinary-differential-equations)), `solve()` expects either expressions which it will assume equal to zero, or `Equality` objects, which we can conveniently create with `Eq()`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANUAAAAZCAYAAACmamtMAAAABHNCSVQICAgIfAhkiAAABr1JREFU\neJzt3HuMHXUVwPHPltpuLW1BqW54WGl5rG8qxqCCoUZMlKAFUYkQ0wCKEBVMUVGivRFRedWoBDUa\ni4ogUhqRIEZ8ARJAFMXGiKjRViSK7xdUBeofZ8b+7t2ZuXO3e+/cxftNJrvze8zv3HPu/M75nd9v\nlxEjRgyMPXAuPoW9G5alSY5pWoARPdFve12Ej+NpvXbcG1tx/ExLNMuYxJeaFmJEbQZlr2fgfhxb\nVDm3pNMr8Ud8vk9CdeODuAZ341/YFy/H53Bv0m451mEbHsZCvAO/nSE5XosrOsoOwSl4EAuy61xs\n7vKsM/EYfGCGZBsm6upkurqry6DstVm8G6dhY13hWvh23cZ9YHvH9TDe3dFmX/xBu7s/AXcpnyx6\n5U5hhJyV+DLGk7JL8DccVPGcZfin0Oujjbo6ma7uemGQ9mrhtqKKOd3lbISt+KTwVuvxbJzT0eZD\nQv7U3V+NA8XLtbM8Fz8WM1zO63BUduV8BYtwYsWzzsZjZ0CmYaSuTqaru7oMjb2G9aX6Jd6A1Vgr\nvE/KPByJn+ORpPxBbFES6/bI8bi8o+wHYpb7a1K2KPv5QMlzjsE3Z0CeYaWuTqaju14Yenu1NBv+\ndRt7QoSFNxXUfVcsIneGXfAj9cLIC/AQnlVQt6v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tbPF+bwyDsWNYsY8sqTNeSKFe7LwgmMibLlVvNA5u4rkRZ5G\nXYm3iRg3DRNXi/Nf1wrvu1UkVF4i4uuU4/D6Erm2ifXm/fhzUn66ONJyakk/4gxZ+jNnldho3CTW\nBv1mi/Yv2PmZTDeWtO9mr7o66UV3w2yvlJ7D5ZbiDdg9RCr7guxaKLImnxBx6RFdnjspUuPdvNlh\nYiH5WeF+zzF1Nl+QybBBeLcb8LyONou0p//PEjvstwoPkTKh/MuVskbs6VyWjXml9j20lMXC498n\nZr5t2dirs/qnivXMr2qMOxNMitT0xWLWvxl/Ur5mqWuvNerppFu7YbdXSkuJpyqjpdkTFU1whvK0\ncr9pNTDmHHGaf0MDY88ETdqLWXigtglehS82NPb87k12miu0b/q+QuxRvX8AY/eDJu1VSdlL9Q87\nDh7+P7Af/iJOaAyaVfj+AMY5wo5waU9xBGyNWMjPNpq0V85uIlNdm73EAvGkvogzfLzHzPy5SK/M\nNbizgceKxMSFYjP1kAGN2w+aslfOwWLd9dJeOy4RRrjUo/9/VFyrePNxxHDSpL0+LBJz+zc0/ogR\nI0aMGDFixIjh4r/AsP+iG7cDZwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$\\left \\{ x : \\frac{59 z}{34}, \\quad y : \\frac{33 z}{34}\\right \\}$$"
      ],
      "text/plain": [
       "⎧   59⋅z     33⋅z⎫\n",
       "⎨x: ────, y: ────⎬\n",
       "⎩    34       34 ⎭"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sympy import symbols,solve,Eq\n",
    "x, y, z = symbols('x,y,z')\n",
    "solve((Eq(3*x+7*y,12*z), Eq(4*x-2*y,5*z)), x, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANUAAAAZCAYAAACmamtMAAAABHNCSVQICAgIfAhkiAAABr1J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12miu0b/q+QuxRvX8AY/eDJu1VSdlL9Q87\nDh7+P7Af/iJOaAyaVfj+AMY5wo5waU9xBGyNWMjPNpq0V85uIlNdm73EAvGkvogzfLzHzPy5SK/M\nNbizgceKxMSFYjP1kAGN2w+aslfOwWLd9dJeOy4RRrjUo/9/VFyrePNxxHDSpL0+LBJz+zc0/ogR\nI0aMGDFixIjh4r/AsP+iG7cDZwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$\\left \\{ x : \\frac{59 z}{34}, \\quad y : \\frac{33 z}{34}\\right \\}$$"
      ],
      "text/plain": [
       "⎧   59⋅z     33⋅z⎫\n",
       "⎨x: ────, y: ────⎬\n",
       "⎩    34       34 ⎭"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solve((3*x+7*y-12*z, 4*x-2*y-5*z), x, y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For more information, see `help(solve)` and `help(solve_linear_system)`.\n",
    "\n",
    "### Non linear equations\n",
    "\n",
    "Let’s solve a simple equation such as\n",
    "$x = x^2$. There are two obvious solutions: *x* = 0 and *x* = 1. How can we ask Sympy to compute these for us?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import sympy\n",
    "x, y, z = sympy.symbols('x, y, z')        # create some symbols\n",
    "eq = x - x ** 2                           # define the equation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADkAAAAWCAYAAAB64jRmAAAABHNCSVQICAgIfAhkiAAAAblJREFU\nWIXt179rFEEYxvGPehpJNBqRgIhYqAQRLBRJm1iI/g/6B9iIIDZWNmJrky5FIAQEtZKAIMiWgkgC\nWtlFRDljIcqBaESL2cBm2Ql3tzuJP/Jt3rn3nZl9nt1Z9j3+A7aVfj/BNzzFFMZwF0v4hYO4ifYG\naowxiOc4Xcpfw3nsxsWqhVlhvA/vcLmQu4XX2NWQ0H45hxfCjY+RdVO4g49oFXIH8ANX+5ZXj5OY\nx4zwFGubfIPHFXNe4Vmv6hIwo0uT2yMT9uIE3lbU3uNsn8I2hZjJo3n8UlHrYBgDSRQlIGZyOI/f\nK2qdPO5vXk4aYiZ/5rHqzO/M447m5aQhZnJ5nTVDefzasJZkxEy2hac4UlEbwmf/gMkOFnCkonYc\ni8kUJSBmkvDRHbe29TsmGH9QmjsmtFF/BVlhfEg4llcKuXtCM1Bs6yaFo/0otbgS9/PrDkbq2eqg\nFZkAHzAhtHdnsEdo6y5Z+2lp45ONaRBGMYvDOJXnloR+ehpz3WyS1RBwu8baFGSrg/XeyV75Yzug\npkxO4mVDezVO2eSK8Mf5eg97tHABD5sSVZMbgoeVzRayxRZ98BurMkmtl8geLgAAAABJRU5ErkJg\ngg==\n",
      "text/latex": [
       "$$\\left [ 0, \\quad 1\\right ]$$"
      ],
      "text/plain": [
       "[0, 1]"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.solve(eq, x)                        # solve eq = 0"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The `solve()` function expects an expression that as meant to be solve so that it evaluates to zero. For our example, we rewrite\n",
    "\n",
    "*x* = *x*<sup>2</sup>\n",
    " as\n",
    "*x* − *x*<sup>2</sup> = 0\n",
    " and then pass this to the solve function.\n",
    "\n",
    "Let’s repeat the same for the equation:\n",
    "*x* = *x*<sup>3</sup>\n",
    " and solve"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHQAAAAWCAYAAAARprh2AAAABHNCSVQICAgIfAhkiAAAAgRJREFU\naIHt2c+LjVEcx/EXxo9mMihZkQWaWPiRZD0W8j+wkaVIiYXV7CytRLGYjVJYaYoUd6kkxEJWSGqa\njeiWNBqL89x6PPPc2/15zjM877qde8/3ud1330/nPPeeS80/xarC60f4iSe4HslhHM+xP9LndWIK\nV/EJS9iKS5hPKaV9j87jGDbgRNkbGyPVWs4RvBCal5pN+IJTubkreId1SYwC3fSo0XqyetQ2bdiL\nOZzF70QORS4Lwd3Nzd0UVu2ZBD5D6VFjWDY9MKsaK/QDHpbMv8XTyC5FZlV8hVaNjdiDzyW1rzgc\nV6d/6kADO7Pxe0mtiUmsj6fTP3Wggcls/FVSa2bj5kguA1EHGmh96Si7T63NxjWRXAZirIdrDwg3\n5+Jv13a8wulehRKx0KE2kY0/YogMSi+BvsGhUYkkZl5YnVtKahP4ZoUEWm+5gaawo+woqe3G67g6\n/bMSAp0SjrZGzRyO+vuWsksI+V4ip56pQqCtxoyX1KbxHncieNwQttf80d854ejvdiKnFp161JHG\ncD3asg2PhWYtZY8FPMPJ3HX7svmPkbwOCiv1Gm7hAbYXronl1G2P6JBb20JiZlILlDCTWiBHo/Wk\nCltuN1TxlKaKTisi0Gm8TC1RoIpOWB7oovAn94UELmWM4TjupxbJUSWni0Jei6lFampqav5D/gC/\n7lwPZzMlQQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$\\left [ -1, \\quad 0, \\quad 1\\right ]$$"
      ],
      "text/plain": [
       "[-1, 0, 1]"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eq = x - x ** 3                           # define the equation\n",
    "sympy.solve(eq, x)                        # solve eq = 0"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Output: LaTeX interface and pretty-printing\n",
    "\n",
    "As is the case with many computer algebra systems, SymPy has the ability to format its output as LaTeX code, for easy inclusion into documents.\n",
    "\n",
    "At the start of this chapter, we called:\n",
    "\n",
    "```python\n",
    "sympy.init_printing()\n",
    "```\n",
    "\n",
    "Sympy detected that it was in Jupyter, and enabled Latex output. The Jupyter Notebook supports (some) Latex, so this gives us the nicely formatted output above.\n",
    "\n",
    "We can also see the plain text output from Sympy, and the raw Latex code it creates:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "y**2/x**3 - y/x**2 + 1/x + O(y**3)\n"
     ]
    }
   ],
   "source": [
    "print(series(1/(x+y), y, 0, 3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\\frac{y^{2}}{x^{3}} - \\frac{y}{x^{2}} + \\frac{1}{x} + \\mathcal{O}\\left(y^{3}\\right)\n"
     ]
    }
   ],
   "source": [
    "print(latex(series(1/(x+y), y, 0, 3)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "$\\frac{y^{2}}{x^{3}} - \\frac{y}{x^{2}} + 1 / x + \\mathcal{O}\\left(y^{3}\\right)$\n"
     ]
    }
   ],
   "source": [
    "print(latex(series(1/(x+y), y, 0, 3), mode='inline'))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Be aware that in its default mode, `latex()` outputs code that requires the `amsmath` package to be loaded via a `\\backslashusepackage{amsmath}` command in the document preamble.\n",
    "\n",
    "SymPy also supports a “pretty print” (`pprint()`) output routine, which produces better-formatted text output than the default printing routine, as illustrated below. Note features such as the subscripts for array elements whose names are of the form `T_n`, the italicised constant *e*, vertically-centred dots for multiplication, and the nicely-formed matrix borders and fractions.\n",
    "\n",
    "<img src=\"static/images/sympy.png\" alt=\"Nicely-formatted output from pprint().\" style=\"width:60.0%\" />\n",
    "\n",
    "Finally, SymPy offers `preview()`, which displays rendered output on screen (check `help(preview)` for details)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### Automatic generation of C code\n",
    "\n",
    "A strong point of many symbolic libraries is that they can convert the symbolic expressions to C-code (or other code) that can subsequently be compiled for high execution speed. Here is an example that demonstrates this:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOgAAAAbCAYAAAB2r8PPAAAABHNCSVQICAgIfAhkiAAAB6tJREFU\neJzt3HuwVVUdwPEPQqKCikaKEnkzVMAcS5KQEC3Fmcb+yEhQMM3EKRtNe/yTZSE9TcscZ2xK00Nk\nMGIvjTKbMXspEWaF9tR0jCyltFSMpKQ/fnt399l3n3v2Ofc8LpfznbnD3Wuvtdfvt56/32+tCz16\n9OjRo23MwmSMwiTM7q44I5LjcGwbvz8Wl2NMG+voGsfidJyDlXhtd8XpOBVsx39xNw7pqjQjj8Nw\nWYu+dSY+iKV4b+7dq/DJFtUzrPgbzkp+PxVbML5k2Te1RaLOskzsnJOaKDsS9G83N2OvFnznrfon\nYB+ew8RcnmswswV1DStejnHJ76diG/YsUW4avtEuoTrIsibLjRT9G2E03o+rk+fjcRuewhP4EiZk\n8s8Vk2ao7IrNOCiTdnBBvmlY04L6hi2r8KGSeZdjUUH6ofgKvig659PKTfhucbkw7xfjBhxeslwt\n/WEP/GqQsrPwNXwHG0VbTS7Id1iS70p8RkyA/UvK12om4Ha8R/jrn8IKzBcm58PCVbg1U+ZGHNOC\nuo9Lvj0PS0RbnFQj7y+wTwvqHFbMErb99WJwleHn2D2XNgOPYE7yPAkPaW6XekETZZrhGDHgiMH2\nO+xSolyR/nA0fiYGVBFHiYGe7jTj8UM8Lky3lL2xCWdk0i7GfWJHaZShtOc+2KDfpF9moPVwkNhJ\nt2N6kvaw5mTNszj5bhpoGo9/4MUFeb+AhS2oc1jyDtyjvg86SwSUsowRg/uiTNoUYZpc2IQs1yre\nVVpNNvLXJwbCkXXKFOk/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7\nZLhZ3Dwq4nERjs/zg0SOAxqsq2JoUdxO65+lotwkXinMwjzjhJl3VcG7O0QgpFEqGm/P9arPNQfj\nFlyXS7tJ/YBWq/vpfpmLMbWiuCeIlequTFrRuVE7abUMe4tV+L4a79eJ6FqedOccbFdoB53Wv1GW\nCb8re3PrzOTfLcJSmlJQbqowsztBanYurZPvXBFMyh97XI8Fdcq2sp+OFu32f+sinaC7i6tPRyTP\n88VVr2cz+YZqXtWj3TIsENfOarFKRB+zPugocbZ6i+ajnmXptv6NcIaQ5yO59LmZ39cKXzTr+rxM\nTNpO3Te9TuzkF6h97vsuccNnvv7jqpTbhLmdjei2s58ukPE/sywQipwmBuRG/Djz/hKtuZM4GO2W\n4XbVl5Xz7CKCBNnGXSh2zr4m6qs0WK7b+mdJAzlFRw3zRJt8OfezWixyKQeIM+W3ZNI+K/Rq5vpc\nRXP9sFzosk1M2FPEUdN5+L64mzsYs1T/GVi7+mm+uMhfyESxnV+e/IwTzvrnRTh5fhMVNko7ZZgk\nfMl67CsGwhoR/FglVv1mqGhsQHVb//3wXWECb09+NotBvCST7++Z9/mf/I76CrGTXikCSV9VfP+0\nDBXN+/RnC9NxqzAf14uJlL8NVYtF+n3MdvTTrviA8oHWEcdF4o5jJ6lo/1W/snRD/1ZTMXzas0eL\n+YmBfxzbbo7Sub9oqUc39G81w6k9e7SQqcLM2lnZ2fXfodnRL8uXYbHq4MXOxs6uf49hzq3K/x9F\nI5GdXf8ePXr06NGjR48ePXoMH/4HWQLWSpe7eV0AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$x - \\frac{x^{3}}{6} + \\frac{x^{5}}{120} + \\mathcal{O}\\left(x^{6}\\right)$$"
      ],
      "text/plain": [
       "     3     5        \n",
       "    x     x     ⎛ 6⎞\n",
       "x - ── + ─── + O⎝x ⎠\n",
       "    6    120        "
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sympy import *                                                                                    \n",
    "from sympy.utilities.codegen import codegen                                                                            \n",
    "x = Symbol('x')                                                                                                          \n",
    "sin(x).series(x, 0, 6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/******************************************************************************\n",
      " *                       Code generated with sympy 1.0                        *\n",
      " *                                                                            *\n",
      " *              See http://www.sympy.org/ for more information.               *\n",
      " *                                                                            *\n",
      " *                       This file is part of 'project'                       *\n",
      " ******************************************************************************/\n",
      "#include \"taylor_sine.h\"\n",
      "#include <math.h>\n",
      "\n",
      "double taylor_sine(double x) {\n",
      "\n",
      "   double taylor_sine_result;\n",
      "   taylor_sine_result = x - 1.0L/6.0L*pow(x, 3) + (1.0L/120.0L)*pow(x, 5) + O(x**6);\n",
      "   return taylor_sine_result;\n",
      "\n",
      "}\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# NBVAL_IGNORE_OUTPUT\n",
    "print(codegen((\"taylor_sine\",sin(x).series(x,0,6)), language='C')[0][1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Related tools\n",
    "-------------\n",
    "\n",
    "It is worth noting that the SAGE initiative <http://www.sagemath.org/> is trying to “create a viable free open source alternative to Magma, Maple, Mathematica and Matlab.” and includes the SymPy library among many others. Its symbolic capabilities are more powerful than SymPy’s, and SAGE, but the SymPy features will already cover many of the needs arising in science and engineering. SAGE includes the computer algebra system Maxima, which is also available standalone from <http://maxima.sourceforge.net/>."
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
